如何防止 ImageMagick 在旋转过程中使图像尺寸加倍?
我有一个最佳压缩的 png,我使用 ImageMagick 将其旋转 1 度 -
convert -rotate 1 crab.png crab-rotated.png
大小从 74 KB 到 167 KB。如何最大限度地减少这种增加?
原始:
旋转:
I have an optimally compressed png that I'm rotating by 1 degree using ImageMagick -
convert -rotate 1 crab.png crab-rotated.png
The size goes from 74 KB to 167 KB. How do I minimize that increase?
Orginal:
Rotated:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件大小的增加可能是由于压缩效率较低所致。除非降低压缩级别(
-quality
选项)或使用更有效但有损的压缩方法(例如 JPEG),否则您将无法对此执行任何操作。这就是我认为发生这种情况的原因(如果我错了,希望有人能纠正我)。通过旋转图像,您可以引入原始图像中不存在的空间频率。如果在压缩过程中不抑制这些频率,文件大小将不可避免地增加。但是,抑制这些频率可能会降低图像质量。这是一种微妙的平衡。
旋转后文件大小的增加(或减少)量取决于图像中已经存在的频率,即它是图像特定的。
The increase in file size is probably due to less efficient compression. You won't be able to do anything about that unless you decrease the compression level (
-quality
option) or use a more efficient but lossy compression method (e.g. JPEG).Here's the reason why I think this happens (I hope somebody can correct me if I am wrong). By rotating the image, you are introducing spatial frequencies that were not present in the original image. If these frequencies are not suppressed during compression, than the file size will inevitably increase. However, suppressing these frequencies may degrade the quality of your image. It's a delicate balance.
The amount of increase (or decrease) in filesize after rotation depends on the frequencies already present in the image, i.e. it is image-specific.