为什么Imagemagick或GraphicsMagick在调整到较小尺寸时会增加PNG图像的MB大小? [英] Why do Imagemagick or GraphicsMagick increase the MB size of my PNG image when resizing to a smaller dimension?

查看:227
本文介绍了为什么Imagemagick或GraphicsMagick在调整到较小尺寸时会增加PNG图像的MB大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从png转换为png。

I need to convert from png to png.

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

I am using ImageMagick 6.8.7-7 on Mac OS X to decrease the dimension of my png.

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

Here is an exact example : start.png : 20866 × 8957 = 6.6 MB

start.png是详细的平面图只是黑色和白色

start.png is a detailed floor plan just black and white

转换start.png -resize 16384x7033 out.png

convert start.png -resize 16384x7033 out.png

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

Result is out.png 16384 × 7033 = 36.9 MB (even convert start.png -resize 16384x7033 out.jpg => out.jpg 22.7MB)

如果我申请 pngquantto out.png我可以减少到15MB

If I apply "pngquant" to out.png I can reduce to 15MB

为什么会出现这种增长?

Why does this increase happen?

我正在寻找对于转换选项不会增加out.png的大小?

I am looking for a option on convert which will not increase the size of out.png?

编辑
如果我提供更多信息可能会有帮助...
我在两个文件上执行了识别-verbose并获得了以下输出:

EDIT Maybe it helps if I provide more infos... I executed "identify -verbose" on both files and got following output:

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

**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*


推荐答案

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

The reason the filesize increases is that your resize operation increases the number of colors. You could replace "resize WxH" with "-sample WxH" to only use the existing (black and white) colors.

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

If you're using ImageMagick, you might as well remove the ICC profile too, with "-define png:exclude-chunk=iCCP", because it's not of much use in a black-and-white image. This option isn't yet available in GraphicsMagick.

这篇关于为什么Imagemagick或GraphicsMagick在调整到较小尺寸时会增加PNG图像的MB大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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