本文介绍了PHP-清除PNG元数据,但保持相似的质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将每个上传的图像都转换为png.我认为gd是个好方法,因为它会丢弃图像的元数据,并且不会尝试对其进行解析.我读到ImageMagick可能在某些linux服务器上存在恶意软件漏洞...

I want to convert every uploaded image to png. I think gd is a good approach for that, because it drops the metadata of the images, and does not try to parse it. I read that ImageMagick maybe has malware vulnerability on some linux servers...

我有2个问题:

  1. 如果原始文件是PNG,gd也会删除PNG元数据吗?还是在转换后应该使用pngcrush?
  2. 我是否有与保存JPEG文件相同的质量损失,还是PNG格式好得多?

推荐答案

如果您要在PHP中打开png,请将其复制到新资源中,然后以完整质量保存(在PNG中,JPEG将失去质量),它将做你想做的事.

If you would open the png in PHP, copy it to a new resource, then save it at full quality (in PNG, JPEG will lose quality) it will do what you want.

这篇关于PHP-清除PNG元数据,但保持相似的质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:35