dongshuo8756 2015-05-12 13:45
浏览 256

压缩图像质量(从4MB到2MB)而不会丢失其尺寸

I am trying to compress the quality of an image using ImageMagick. I mean that I have an image which dimension is 1600X800 and size is 4MB. Now I am trying to compress the quality of this image into 2MB without resizing its dimensions, means the newly generated image also have the same dimension as actual image (i.e. 1600X800) but the quality of this image should be compress into 2MB (half of the actual image). For this, now I am using the below code, but this is not compress the size of the newly created image:

$src_img = "src.png";
$dest_img = "dest.png";
exec("convert $src_img -quality 90 $dest_img");

So can anyone please tell me what can I do to compress the size of the image without losing its actual dimension using ImageMagick?

  • 写回答

2条回答 默认 最新

  • dongxiezhi0590 2015-05-12 14:06
    关注

    You can change image quality using GD library functions. It is more secure than using exec().

    $im = imagecreatefrompng("src.png");
    
    imagepng($im, 'dest.png', $quality);
    imagedestroy($im);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制