dongyuan8024 2017-04-08 16:08
浏览 38

重叠图像,但保持压缩

I am using this code to overlap 3 partly transparent images into 1, also partly transparent.

$x=3843;
$y=3402;
$final_img = imagecreatetruecolor($x, $y); // where x and y are the dimensions of the final image
    imagesavealpha($final_img, true);

    $trans_colour = imagecolorallocatealpha($final_img, 0, 0, 0, 127);
    imagefill($final_img, 0, 0, $trans_colour);

$image_1 = imagecreatefrompng('1.png');
$image_2 = imagecreatefrompng('3.png');
$image_3 = imagecreatefrompng('6.png');

imagealphablending($final_img, true);
imagesavealpha($final_img, true);

imagecopy($final_img, $image_1, 0, 0, 0, 0, $x, $y);
imagecopy($final_img, $image_2, 0, 0, 0, 0, $x, $y);
imagecopy($final_img, $image_3, 0, 0, 0, 0, $x, $y);



imagepng($final_img, 'final_img.png');

Each image was compressed before overlapping and has the size 100KB. Once overlapped and saved, the final_img.png, has the size 1,1MB. Big difference. How can preserve the compression of the final image without the extra step of compression the image again? What methods or libraries should I use?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘