【发布时间】:2020-07-22 18:09:57
【问题描述】:
我在我的 Laravel 应用程序中组合了两个图像,它可以在我的本地机器上运行。但是底部图像在我的 Ubuntu 服务器上消失了。所有图像均小于 100kb。内存限制设置为 -1。
注意:在合并之前,我将顶部图像转换为与底部图像具有相同宽度。
$top_image_path = '/textImage.jpg';
$bottom_image_path = '/blueImage.jpg';
list($top_image_width, $top_image_height) = getimagesize($top_image_path);
list($bottom_image_width, $bottom_image_height) = getimagesize($bottom_image_path);
$merged_width = $bottom_image_width;
$merged_height = $top_image_height + $bottom_image_height;
$merged_image = imagecreatetruecolor($merged_width, $merged_height);
imagealphablending($merged_image, false);
imagesavealpha($merged_image, true);
$img1 = imagecreatefromjpeg($top_image_path);
$img2 = imagecreatefromjpeg($bottom_image_path);
imagecopy($merged_image, $img1, 0, 0, 0, 0, $top_image_width, $top_image_height);
imagecopy($merged_image, $img2, 0, $bottom_image_width, 0, 0, $bottom_image_width, $bottom_image_height);
imagejpeg($merged_image, 'merged_image.jpg');
结果:
【问题讨论】:
标签: php image-processing