【发布时间】:2014-02-08 11:49:49
【问题描述】:
我需要从 png 转换为 png。
我在 Mac OS X 上使用 ImageMagick 6.8.7-7 来减小我的 png 的尺寸。
这是一个确切的例子:start.png : 20866 × 8957 = 6.6 MB
start.png 是一个黑白的详细平面图
转换 start.png -resize 16384x7033 out.png
结果为 out.png 16384 × 7033 = 36.9 MB (甚至转换 start.png -resize 16384x7033 out.jpg => out.jpg 22.7MB)
如果我对 out.png 应用“pngquant”,我可以减少到 15MB
为什么会出现这种增长?
我正在寻找一个不会增加 out.png 大小的 convert 选项?
编辑 如果我提供更多信息可能会有所帮助... 我对两个文件都执行了“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*
【问题讨论】:
-
png 就像 zip - 您可以指定所需的压缩级别。更少的压缩 = 更快的文件生成,但通常比压缩更高的文件需要更多的空间 - 这反过来需要更多的 cpu 时间,但给你一个更小的文件
-
实际上我在转换上尝试了一些压缩选项,例如 05 等。有时这会将 out.png 增加到 100MB。你知道一个好的压缩值吗?
-
它从“Palette”变为“TrueColor”……这可能与它有关吗?
-
在不知道自己在做什么的情况下,我尝试了 convert start.png -type palette -resize 16384x7033 out.png 但出现错误转换:“调色板图像所需的有效调色板 `out.png' @错误/png.c/MagickPNGErrorHandler/1804。”
-
添加 png8:filename 有帮助
标签: imagemagick graphicsmagick