为什么“转换x.png y.png”创建一个不同大小(KB)的图像? [英] Why does "convert x.png y.png" creates an image with a different size (KB)?

查看:201
本文介绍了为什么“转换x.png y.png”创建一个不同大小(KB)的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些图像,我试图通过调整大小来规范化到一定的比例。
当我开始调整图像大小时,我注意到它们的体积(KB)变得比原始图像大得多。

I have a few images I'm trying to normalize to a certain scale by resizing them. When I started resizing the images, I noticed that their volume (KB) became much larger than the original image.

我通过简单的操作进一步检查了它:
兑换x.png y.png
并且有所不同。例如。在一种情况下,x.png是143KB,y.png是208KB。

I checked it out further by simply doing: convert x.png y.png And got some difference. E.g. in one case x.png is 143KB and y.png is 208KB.

由于我也在优化图像大小,我想知道是否有人知道为什么这个是这样的,以及任何解决这个问题的建议。

Since I'm also optimizing for image size, I was wondering if anyone has an idea why this is the case and any suggestions to solve this.

我在Windows 7上使用Imagemagick 6.6.4-Q16。

I'm using Imagemagick 6.6.4-Q16 on windows 7.

谢谢,Amit

编辑:

感谢您的建议,伙计们,对不起的回复感到抱歉!这是我试图做的,这是结果。原始图像为112KB。不使用参数进行转换会产生169KB图像。使用OptiPNG(PNGCrush不适用于我),-o7结果为113KB。然后我尝试在0-99之间为每个X进行转换 - 质量X,并且我发现对于质量90我实现了116KB的文件大小,因此OptiPNG更好。但是 - 当我将-resize转换为较小的图像(按比例)时,我得到199KB没有参数,196KB用于最佳转换质量X(x = 0),196KB用于OptiPNG。
当我希望文件更小时,文件大小增加了75%,因为我将图像从377x2290调整为234x1419,调整了35%。有什么想法吗?

Thanks for the suggestion, guys, and sorry for the late reply! Here's what I tried to do and here are the results. The original image is 112KB. Doing convert with no parameters results in 169KB image. Using OptiPNG on it (PNGCrush didn't work for me) with -o7 results in 113KB. I then tried to do convert -quality X for every X between 0-99, and I found that for quality 90 I achieve a file size of 116KB, so OptiPNG is better. However - when I do convert -resize to a smaller image (proportionally), I get a 199KB with no parameters, 196KB for the best convert -quality X (x=0), and 196KB for OptiPNG. This is 75% increase in file size when I would expect the file to be smaller, since I resized the image by 35% from 377x2290 to 234x1419. Any thoughts?

谢谢!

编辑 - 附图片+调查的调整大小问题:

这是三个图像的链接(查看字幕):原始图像,简单ImageMagick转换后的图像,以及optipng后的相同输出图像。
http://picasaweb.google.com/101622787022351879933/ImageMagickProblem?feat=directlink

Here is a link to the three images (look at the captions): Original image, image after simple ImageMagick convert, and the same output image after optipng. http://picasaweb.google.com/101622787022351879933/ImageMagickProblem?feat=directlink

另外,我认为ImageMagick的resize选项可能存在问题。我做了以下练习来隔离它:
每1-1之间的x:
转换a.png -resize x%a_x.png

Also, I think there might be an issue with the resize option of ImageMagick. I did the following exercise to isolate it: For every x between 1-100: convert a.png -resize x% a_x.png

正如预期的那样,图像的大小几乎不断增加,从1%增加到100%。略有下降40%和50%。问题是,从40%开始,输出图像大小会绕过原始图像大小。只有当你达到100%时,图像尺寸才会大幅回落到原始尺寸(实际上,我的第一次编辑稍微多一点 - 169KB而不是112KB,Optipng后为113KB)。

As expected, the size of the image almost constantly increases from 1% to 100%. There is a slight drop in 40% and in 50%. The issue is that from 40% and on, the output image size bypasses the original image size. Only when you hit 100% there is a large drop in image size back to the original size (slightly more actually, per my first edit - 169KB instead of 112KB, and 113KB after Optipng).

即使在每个输出文件上运行带有-o7的Optipng也无法解决此问题。

Even running Optipng with -o7 on each output file doesn't correct this.

您可以在下图中看到此实验的结果:
http://picasaweb.google.com/lh/photo/fFL1W6SiUfFWhBqdUf3BZg? feat = directlink

You can see the results of this experiment in the graph below: http://picasaweb.google.com/lh/photo/fFL1W6SiUfFWhBqdUf3BZg?feat=directlink

推荐答案

好的,问题在于迈克尔建议的过滤器。

Ok, the issue was with the filters per Michael's suggestion.

这是我做的:

convert -list filter > 1.txt

获取所有过滤器的列表。
然后,对于每个x,该列表上的过滤器,我做了:

to get a list of all filters. Then, for every x which is a filter on that list, I did:

convert -filter x -resize 234x1419 a.png b_x.png

我记录了文件大小,然后做了optipng -o7在每个文件上。

I recorded the file size, and then did "optipng -o7" on each file.

对于我的案例,此图像的最佳过滤器是Box:它是唯一一个实际从112KB减少到111KB,然后到81KB by optipng。

The best filter for this image for my case was "Box": it was the only one that actually got reduced from 112KB to 111KB, and then to 81KB by optipng.

我认为有趣的是,在所有这一过程之后,只有Box过滤器实际上减少了图像的大小,即使它们都是调整大小后的像素数量减少。

I think it is interesting to note that after all this process, only the Box filter actually got the size of the image reduced, even though all of them have less pixels after the resize process.

BTW:注意以下陷阱

convert -filter Box -resize 234x1419 a.png a_box.png

产生112KB的图像,可以压缩到81KB,如上所述。但是:

results in an image of 112KB which can be compressed to 81KB, as I said above. However:

convert a.png -filter Box -resize 234x1419 a_box.png

会产生199KB的图像!

results in an image of 199KB!

这篇关于为什么“转换x.png y.png”创建一个不同大小(KB)的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆