使用 PHP magickwand 压缩 PNG
我想知道如何正确压缩 PNG 图像。
情况是这样的:
我有一个在 Windows 上用 Irfanview 压缩和减色的 PNG 图像。 大约有20KB。 当我的门户软件使用默认值调整大小(使用 magickwand 1.0.7)时,它大约是 63K(!)。
接下来的尝试是调用 MagickSetImageDepth($this->_imageHandler,8),结果文件大小为 34K,这更好,但仍然比(尺寸更大)原始文件大。
所记录的功能似乎都不适合进一步压缩图像。
任何提示将不胜感激!
问候, 索萨
I'm wondering how to compress an PNG image correctly.
The situation is this :
I have a PNG image compressed and color-reduced with Irfanview on Windows. It's about 20KB.
When my portal software resizes (using magickwand 1.0.7) it with default values, it's about 63K (!).
Next try was to call MagickSetImageDepth($this->_imageHandler,8), resulting in a filesize of 34K, which is better, but still it's bigger than the (larger in dimension) original file.
None of the documented functions seem to fit to further compress the image.
Any hint would be greatly appreciated !
Greetz,
Sosa
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PNG 压缩程序和例程使用不同的技术。 我发现很多时候,已经压缩(或有效保存)的图像无法进一步压缩,甚至无法像您所遇到的那样具有更大的文件大小。
在你的情况下,我想说你的图像不能进一步压缩,至少使用 MagickWand 是这样。 您可能只想省略该步骤。
也许在运行之前优化 PNG 是一个解决方案。 在这种情况下,有多种选择。 我很幸运地使用了 PNGGauntlet。 您可以在 PNGGauntlet 上运行批处理作业,它会跳过它会变大的文件(如果有)。
PNG compression programs and routines use different techniques. I've found out that many times, an image that's already been compressed (or saved efficiently) cannot be compressed further or even has a higher file size as you are experiencing.
In your case I'd say your images cannot be compressed further, at least using MagickWand. You might just want to leave out that step.
Perhaps optimizing your PNGs before runtime would be a solution. There are many options available in this case. I've had luck with PNGGauntlet. You can run a batch job on PNGGauntlet and it will skip over the files that it would've made larger, if any.
试试雅虎的这个工具 - 太棒了!
http://developer.yahoo.com/yslow/smushit/
Try this tool by Yahoo - it's great!
http://developer.yahoo.com/yslow/smushit/