Compression 使用alpha通道收缩我的png

Compression 使用alpha通道收缩我的png,compression,alpha-transparency,Compression,Alpha Transparency,首先,我不是一个图形程序员,我可能不知道我想做什么的正确术语。我知道我想做什么,但不知道怎么做。我将尝试描述我想要的,但请记住,我可能使用的术语不正确。也许有比我认为我需要做的更好的方法来做我想做的事情 我的主要目标是:我有一个大约250000字节大小的图片,我想使文件的大小更小 请注意,原始图片是全亮度的,但我使用了gimp(可能不正确)使其具有褪色的外观。我认为它现在有一个“alpha通道”,带有一些不透明度百分比值。因此,我认为图片以全亮度存储在rgb通道中,还有另一个alpha通道描述图

首先,我不是一个图形程序员,我可能不知道我想做什么的正确术语。我知道我想做什么,但不知道怎么做。我将尝试描述我想要的,但请记住,我可能使用的术语不正确。也许有比我认为我需要做的更好的方法来做我想做的事情

我的主要目标是:我有一个大约250000字节大小的图片,我想使文件的大小更小

请注意,原始图片是全亮度的,但我使用了gimp(可能不正确)使其具有褪色的外观。我认为它现在有一个“alpha通道”,带有一些不透明度百分比值。因此,我认为图片以全亮度存储在rgb通道中,还有另一个alpha通道描述图片的“淡入度”。图像应该淡入“白色”-它将被放置在白色背景上,上面有黑色文本-但我认为我还没有在图像中存储最后一点信息(尚未)

因此,我试图做到这一点:我认为如果我只指定rgb通道中褪色图片的实际像素值,并去掉alpha通道,图片可能会更小。此外,总体上应该有较少的颜色,我可以使用彩色地图,使图片更小。褪色的图片褪色程度足以使文字在其上书写时清晰可辨——即,它相当褪色——因此颜色应该比全亮度版本少得多

然而,我不知道如何做到这一点,或者在文档中查找什么。我尝试了一些“压缩”程序,得到的最佳压缩率约为2.5%。很明显,我找的地方不对,因为我认为应该压缩到比这个小得多的地方

以下是imagemagick的“标识-详细”输出:

bjb@rhino:~/work/mojatatu/admin/2015/web/foo/img/work$identify-verbose../orig/joannrobins-penguins-snow-banner-falled.png 图片:../orig/joannrobins-penguins-snow-banner-failed.png 格式:PNG(便携式网络图形) 类别:DirectClass 几何图形:799x152+0+0 分辨率:137.8x137.8 打印尺寸:5.79826x1.10305 单位:像素分光光度计 类型:TrueColorAlpha Endianess:未定义 色彩空间:sRGB 深度:8位 航道深度: 红色:8位 绿色:8位 蓝色:8位 阿尔法:8位 频道统计: 红色: 最低:0(0) 最大值:255(1) 平均数:145.053(0.568837) 标准偏差:51.0466(0.200183) 峰度:0.897068 偏度:-1.18367 绿色: 最低:0(0) 最高:253(0.992157) 平均数:152.236(0.597003) 标准偏差:53.6199(0.210274) 峰度:0.941151 偏度:-1.2307 蓝色: 最低:0(0) 最高:251(0.984314) 平均数:164.608(0.645521) 标准偏差:56.552(0.221772) 峰度:1.13143 偏度:-1.37866 阿尔法: 最低:84(0.329412) 最高:84(0.329412) 平均数:84(0.329412) 标准偏差:0(0) 峰度:0 偏度:0 图像统计: 总体而言: 最低:0(0) 最大值:255(1) 平均数:158.224(0.620487) 标准偏差:46.5805(0.182669) 峰度:2.94443 偏度:-1.70687 渲染意图:感知 伽马:0.4545 色度: 红色小学:(0.64,0.33) 绿色小学:(0.3,0.6) 蓝色小学:(0.15,0.06) 白点:(0.3127,0.329) 交错:无 背景颜色:白色 边框颜色:srgba(223,1) 哑光颜色:灰色74 透明颜色:无 作曲:结束 页面几何图形:799x152+0+0 处置:未定义 迭代次数:0 压缩:拉链 方向:未定义 特性: 日期:创建日期:2015-03-21T19:32:58-04:00 日期:修改日期:2015-03-21T19:32:58-04:00 找到png:bKGD:chunk(请参见上面的背景色) png:cHRM:chunk被发现(见上面的色度) png:gAMA:gamma=0.4544(见上文gamma) png:IHDR.bit_深度:8 png:IHDR.color_类型:6(RGBA) png:IHDR.interlace\u方法:0(非隔行) png:IHDR.宽度,高度:799152 png:pHYs:x_res=13780,y_res=13780,单位=1 png:sRGB:intent=0(请参见渲染意图) 签字:6ceec80b4c3c05a631de400d74928ca4cb86bd9f304676ecd4a475b874a71cfc 人工产品: 文件名:../orig/joannrobins-penguins-snow-banner-failed.png 详细:正确 污点:假 文件大小:248KB 像素数:121K 每秒像素数:0B 用户时间:0.000u 运行时间:0:01.000 版本:ImageMagick 6.7.7-10 2014-03-08 Q16http://www.imagemagick.org 我查看了一些ImageMagick文档,并尝试了以下大多数工具(我还不得不收缩a.jpg,发现jpegoptim工作得很好)

设置advancecomp(1.15-1)。。。advpn-z4 file.png。没有看到任何压缩
正在设置jpegoptim(1.2.3-2+b2)。。。竖起两个大拇指-简单有效
设置optipng(0.6.4-1)。。。
设置pngcrush(1.7.9-1)。。。
正在设置pngnq(1.0-2)。。。
正在设置pngquant(1.0-4.1)。。。
设置修剪(1.0.5-1)。。。
幻象转换
转换
-clut(将颜色查找表应用于图像)
-哈尔德克洛特酒店
-独特的颜色

-量化色彩空间不太确定你真正想要什么,但也许这会让你朝着正确的方向前进。如果你想要一个“褪色的外观”,你通常可以通过降低图像的对比度来实现这一点,这样黑色比黑色更灰,白色比白色更灰,或者通过降低饱和度来降低颜色强度,使图片不那么生动或更倾向于黑白

因此,您可以执行以下操作以丢弃alpha通道(透明度),降低对比度并减少图像中的颜色数。文件大小从250kB减小到 bjb@rhino:~/work/mojatatu/admin/2015/web/foo/img/work$ identify -verbose ../orig/joanrobins-penguins-snow-banner-faded.png Image: ../orig/joanrobins-penguins-snow-banner-faded.png Format: PNG (Portable Network Graphics) Class: DirectClass Geometry: 799x152+0+0 Resolution: 137.8x137.8 Print size: 5.79826x1.10305 Units: PixelsPerCentimeter Type: TrueColorAlpha Endianess: Undefined Colorspace: sRGB Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit alpha: 8-bit Channel statistics: Red: min: 0 (0) max: 255 (1) mean: 145.053 (0.568837) standard deviation: 51.0466 (0.200183) kurtosis: 0.897068 skewness: -1.18367 Green: min: 0 (0) max: 253 (0.992157) mean: 152.236 (0.597003) standard deviation: 53.6199 (0.210274) kurtosis: 0.941151 skewness: -1.2307 Blue: min: 0 (0) max: 251 (0.984314) mean: 164.608 (0.645521) standard deviation: 56.552 (0.221772) kurtosis: 1.13143 skewness: -1.37866 Alpha: min: 84 (0.329412) max: 84 (0.329412) mean: 84 (0.329412) standard deviation: 0 (0) kurtosis: 0 skewness: 0 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 158.224 (0.620487) standard deviation: 46.5805 (0.182669) kurtosis: 2.94443 skewness: -1.70687 Rendering intent: Perceptual Gamma: 0.454545 Chromaticity: red primary: (0.64,0.33) green primary: (0.3,0.6) blue primary: (0.15,0.06) white point: (0.3127,0.329) Interlace: None Background color: white Border color: srgba(223,223,223,1) Matte color: grey74 Transparent color: none Compose: Over Page geometry: 799x152+0+0 Dispose: Undefined Iterations: 0 Compression: Zip Orientation: Undefined Properties: date:create: 2015-03-21T19:32:58-04:00 date:modify: 2015-03-21T19:32:58-04:00 png:bKGD : chunk was found (see Background color, above) png:cHRM : chunk was found (see Chromaticity, above) png:gAMA : gamma=0.45454544 (See Gamma, above) png:IHDR.bit_depth : 8 png:IHDR.color_type : 6 (RGBA) png:IHDR.interlace_method: 0 (Not interlaced) png:IHDR.width,height : 799, 152 png:pHYs : x_res=13780, y_res=13780, units=1 png:sRGB : intent=0 (See Rendering intent) signature: 6ceec80b4c3c05a631de400d74928ca4cb86bd9f304676ecd4a475b874a71cfc Artifacts: filename: ../orig/joanrobins-penguins-snow-banner-faded.png verbose: true Tainted: False Filesize: 248KB Number pixels: 121K Pixels per second: 0B User time: 0.000u Elapsed time: 0:01.000 Version: ImageMagick 6.7.7-10 2014-03-08 Q16 http://www.imagemagick.org
  Setting up advancecomp (1.15-1) ...       advpng -z4 file.png.  didn't see any compression
  Setting up jpegoptim (1.2.3-2+b2) ...     two thumbs up - easy and effective
  Setting up optipng (0.6.4-1) ...
  Setting up pngcrush (1.7.9-1) ...
  Setting up pngnq (1.0-2) ...
  Setting up pngquant (1.0-4.1) ...
  Setting up trimage (1.0.5-1) ...


  imagemagic convert

  convert
    -clut (apply a color lookup table to the image)
    -hald-clut
    -unique-colors
    -quantize colorspace  <- reduce colors in this colorspace
    -posterize levels  <- reduce  the image to a limited number of color levels
    -modulate value  <- vary the brightness, saturation, and hue
    -layers method       optimize or compare image layers
    -fuzz distance       colors within this distance are considered equal

    -depth value         image depth


    -alpha remove
  on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel
    -background  white


    - colors value   preferred number of colors in the image
    - colorspace type   set image colorspace
convert yourPengy.png -alpha off +level 65%,95% -colors 256 myPengy.png
convert yourPengy.png -alpha off -modulate 100,80 +level 55%,95% -colors 256 myPengy.png
convert rgba.png -flatten -alpha off rgb-flattened.png
pngcrush -reduce -brute -rem alla rgb-flattened.png rgb.png
convert rgba.png -flatten -alpha off -colors 255 indexed-flattened.png
pngcrush -reduce -brute -rem alla indexed-flattened.png indexed.png