为什么Imagemagick或GraphicsMagick在调整到较小尺寸时会增加PNG图像的MB大小?

时间:2014-01-19 08:57:53

标签: imagemagick graphicsmagick

我需要从png转换为png。

我在Mac OS X上使用ImageMagick 6.8.7-7来减小我的png的尺寸。

这是一个确切的例子:start.png:20866×8957 = 6.6 MB

start.png是一个详细的平面图,只是黑白色

convert start.png -resize 16384x7033 out.png

结果是out.png 16384×7033 = 36.9 MB (甚至转换为start.png -resize 16384x7033 out.jpg => out.jpg 22.7MB)

如果我将“pngquant”应用于out.png,我可以减少到15MB

为什么会发生这种增加?

我正在寻找一个转换选项,它不会增加out.png的大小?

EDIT 如果我提供更多信息,也许会有所帮助...... 我在两个文件上执行了“identify -verbose”并获得了以下输出:


Image: start.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 20866x8957+0+0
Resolution: 98.43x98.43
Print size: 211.988x90.9987
Units: PixelsPerCentimeter
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2014-01-19T09:06:05+01:00
date:modify: 2014-01-17T11:48:05+01:00
png:iCCP: chunk was found
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2

png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 20866, 8957
png:pHYs: x_res=9843, y_res=9843, units=1`
Profiles:
Profile-icc: 2576 bytes
Artifacts:
filename: start.png
verbose: true
Tainted: False
Filesize: 6.603MB
Number pixels: 186.9M
Pixels per second: 41.63MB
User time: 4.480u
Elapsed time: 0:05.490

** OUT.png

Image: out.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 16384x7033+0+0
Resolution: 98.43x98.43
Print size: 166.453x71.4518
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2014-01-19T09:55:41+01:00
date:modify: 2014-01-19T09:55:41+01:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:iCCP: chunk was found
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 16384, 7033
png:pHYs: x_res=9843, y_res=9843, units=1
png:text: 3 tEXt/zTXt/iTXt chunks were found
Profiles:
Profile-icc: 2576 bytes
Artifacts:
filename: out.png
verbose: true
Tainted: False
Filesize: 36.89MB
Number pixels: 115.2M
Pixels per second: 38.54MB
User time: 2.980u
Elapsed time: 0:03.990
Version: ImageMagick 6.8.7-7 Q16 x86_6*

1 个答案:

答案 0 :(得分:1)

文件大小增加的原因是调整大小操作会增加颜色数。您可以将“resize WxH”替换为“-sample WxH”以仅使用现有(黑色和白色)颜色。

如果您正在使用ImageMagick,您也可以使用“-define png:exclude-chunk = iCCP”删除ICC配置文件,因为它在黑白图像中没有多大用处。 GraphicsMagick中尚未提供此选项。