【问题标题】:Tutorial to create a placeholder image [closed]创建占位符图像的教程[关闭]
【发布时间】:2013-01-11 00:38:00
【问题描述】:

我想知道如何在 PHP 中创建占位符图像服务,例如 lorempixel.com 或 dummyimage.com 特别是,如何从文件夹中获取图像并根据 GET 参数对其进行裁剪。 有人吗?

【问题讨论】:

    标签: php image placeholder


    【解决方案1】:

    你应该使用 GD 库

    只需根据参数创建一个具有宽度和高度的新图像

    http://nl1.php.net/manual/en/function.imagecreate.php

    script.php?width=200&height=300

    $width = (int)$_GET["width"];
    $height = (int)$_GET["height"];
    header("Content-Type: image/png");
    $im = @imagecreate($width, $height) or die("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($im, 0, 0, 0);
    imagepng($im);
    imagedestroy($im);
    

    【讨论】:

      猜你喜欢
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-01
      • 2011-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多