需要帮助理解ImageMagick / Graphicsmagick -colors选项 [英] Need help understanding the ImageMagick/Graphicsmagick -colors option

查看:187
本文介绍了需要帮助理解ImageMagick / Graphicsmagick -colors选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式减少(有损)PNG和GIF文件的文件大小。作为其中的一部分,我需要减少图像中的颜色数量。我不想将所有图像缩小为单一颜色值,所以我正在做的是;得到图像中唯一颜色的数量,然后;将此数字除以2可将颜色数减少一半。

I am trying to programmatically reduce (lossy) the file size of PNG and GIF files. As part of this I need to reduce the number of colors in the images. I don't want to reduce all the images to a single colors value, so what I am doing is; get the number of unique colors in the image, then; divide this number by 2 to reduce the number of colors by half.

问题是这不起作用。使用ImageMagic它太慢了,并且不会减小文件大小,除非图像具有几百种独特的颜色。无论原始图像中有多少种颜色,使用GraphicsMagick始终会产生低于255的唯一颜色值。 GraphicsMagick的另一个问题是如果图像中有任何透明像素,它会用透明替换丢失的颜色。

The problem is this does not work. Using ImageMagic it is way too slow and doesn't reduce the file size unless the image has under a few hundred unique colors. Using GraphicsMagick always results in a unique colors value under 255 regardless of how many colors were in the original image. Another problem with GraphicsMagick is if there are any transparent pixels in the image it replaces the lost colors with transparent.

欢迎任何帮助,
谢谢。

Any help would be gratefully welcome, Thanks.

推荐答案

第一个问题,GraphicsMagick可以使用8位,16位或32位量程级别进行编译。我的版本被编译成8位(默认值),这意味着可以分配给图像的最大颜色数是256种独特的颜色(3 * 3 * 2,蓝色位中的1个被删除,因为人眼可以看得不好。显然,GraphicsMagick可以处理比这更多颜色的图像,但是当减少颜色时,它只能减少到256或更少的颜色。较大的像素量子会导致GraphicsMagick运行得更慢并需要更多内存。例如,使用16位像素量子会使GraphicsMagick比支持8位像素量子的速度慢15%到50%(并且占用两倍的内存)。

First problem, GraphicsMagick can be compiled using 8 bit, 16 bit or 32 bit quantum levels. My version is compiled into 8 bit (the default), this means that the max number of colors that can be assigned to an image is 256 unique colors (3*3*2, 1 of the blue bits is removed because the human eye can't see it properly). Obviously, GraphicsMagick can handle images with more colors than this but when reducing colors it can only reduce to 256 or less colors. Larger pixel quantums cause GraphicsMagick to run more slowly and to require more memory. For example, using sixteen-bit pixel quantums causes GraphicsMagick to run 15% to 50% slower (and take twice as much memory) than when it is built to support eight-bit pixel quantums.

第二个问题; PNG图像中的透明度处理,我使用的是早期版本的GraphicsMagick(1.1我认为),无论如何,当我升级到1.3时,这个问题不再存在,这告诉我这是GraphicsMagick 1.1中的一个错误造成的。

Second problem; transparency handling in PNG images, I was using an earlier version of GraphicsMagick (1.1 I think), anyway, when I upgraded to 1.3 this problem is no longer present which tells me that it was a bug in GraphicsMagick 1.1 that caused this.

这篇关于需要帮助理解ImageMagick / Graphicsmagick -colors选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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