繁体   English   中英

使用gd库php增加图像大小并叠加在透明图像上

[英]increase size of image and superimpose on transparent image using gd library php

我将从前端获得图像,我想增加图像的大小并在透明布局上复制该图像。 我想要这个,是因为我只希望我的图像看起来比原始大小大5倍。

$frontimgheight=$frontfeatures['height'];
$frontimgwidth=$frontfeatures['width'];
$frontimgheightnew=$frontimgheight*10;
$frontimgwidthnew=$frontimgwidth*10;

// create transparent layout
$thumbfront = imagecreate($frontimgwidthnew, $frontimgheightnew);
$color = imagecolorallocatealpha($thumbfront, 0, 0, 0, 127);
imagefill($thumbfront, 0, 0, $color);


$dbfrontimg=imagecreatefrompng("./uploads/".$frontimg);
//$dbbackimg=imagecreatefrompng("./uploads/".$backimg);

imagecopyresized($thumbfront, $dbfrontimg, 0, 0, 0, 0,$frontimgwidthnew, $frontimgheightnew, $frontimgwidth, $frontimgheight);
header('Content-Type: image/png');
imagepng($thumbfront);

上面的代码简单地给出了800 x 1000像素的透明图像。

我希望前端图像在透明布局上重叠。

这是我编写的用于执行以下操作的库: https : //github.com/Pamblam/EasyImage

您可以调整图像大小并将其发送回一行:

echo EasyImage::Create("./uploads/".$frontimg)
    ->resize($newWidth, $newHeight);

您还可以进行覆盖和其他各种奇特的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM