【问题标题】:How can I add shadow to an image using the PHP GD library?如何使用 PHP GD 库为图像添加阴影?
【发布时间】:2022-01-11 22:36:52
【问题描述】:

我创建了一个脚本,我使用 PHP GD 库将图像放置在另一个图像的中心。之后,我在该中心放置的图像上方放置了一个 PNG 框架。

我现在想为该图像赋予 3D 效果,或者边缘周围的一些阴影对我有用。我该怎么做?

// Get Product Image sizes
list($width, $height) = getimagesize($filename);
                                
// Load
$source = imagecreatefromjpeg($filename);

// Output
if(isset($frame_image) && !empty($frame_image))
{
    $png = imagecreatefrompng($frame_image);
    list($newwidthf, $newheightf) = getimagesize($frame_image);
    $out = imagecreatetruecolor($width, $height);
    imagecopyresampled($out, $source, 0, 0, 0, 0, $width, $height, $width, $height);
    imagecopyresampled($out, $png,0, 0, 0, 0, $width, $height, $newwidthf, $newheightf);
    $final = imagejpeg($out);
}
else
{
    $final = imagejpeg($source);
}

这是我生成的图像:

【问题讨论】:

标签: php gd


【解决方案1】:

我正在使用 imagescale 和阴影背景,工作

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 1970-01-01
    • 2012-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多