我有两个不同的图像,一个在我的本地机器,另一个在网络中。我想合并这两个图像,我拥有的一切,但我的问题是这两个图像是不一样的宽度和高度。我的本地形象是一个面具,在线图像需要适合本地。本地图像尺寸400x400。是否可以通过裁剪来固定尺寸来使用图像
问题:如果在线图像尺寸低于/大于本地图像尺寸,则图像仅取实际尺寸,不适合蒙版图像。
现在我该怎么做才能让这些图像适合对方?
我做的尝试是[从网上收集] -
//define the width and height of our images
define("WIDTH", 400);
define("HEIGHT", 400);
$dest_image = imagecreatetruecolor(WIDTH, HEIGHT);
//make sure the transparency information is saved
imagesavealpha($dest_image, true);
//create a fully transparent background (127 means fully transparent)
$trans_background = imagecolorallocatealpha($dest_image, 0, 0, 0, 127);
//fill the image with a transparent background
imagefill($dest_image, 0, 0, $trans_background);
//take create image resources out of the 3 pngs we want to merge into destination image
$a = imagecreatefrompng('https://rickwgrundy.files.wordpress.com/2014/01/pt509_stick_figure_podium_speaking-348x370.png');
$b = imagecreatefrompng('400x400.png');
//copy each png file on top of the destination (result) png
imagecopy($dest_image, $a, 0, 0, 0, 0, WIDTH, HEIGHT);
imagecopy($dest_image, $b, 0, 0, 0, 0, WIDTH, HEIGHT);
//send the appropriate headers and save the image in the given link name
header('Content-Type: image/png');
imagepng($dest_image, "result.png", 9);
//destroy all the image resources to free up memory
imagedestroy($a);
imagedestroy($b);
imagedestroy($dest_image);
我的代码可以你给更详细的关于这其实什么ü想 –
这里是我可以提供什么样的一切。我没有别的东西。 – Mysterious
你想合并来自在线图片的本地图片吗? –