用于创建 PNG 8 位透明图像的软件
我正在寻找按照 这篇文章。
注意:我自己需要一个 Linux 解决方案,但请提交其他操作系统的答案。
I'm looking for software to create PNG8 format transparent images as per this article.
NOTE: I need a Linux solution myself, but please submit answers for other OSes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
pngquant 可以很好地转换为 PNG8,同时保持完全透明度。
如果您对尺寸敏感,您可能还会对 pngcrush 感兴趣,它通常可以(无损)对 PNG 文件进行相当程度的压缩。
pngquant does a good job of converting to PNG8 while preserving full transparency.
If you're size-conscious, you may also be interested in pngcrush, which can usually (losslessly) compress PNG files quite a bit.
我还需要一个 Linux 解决方案,并发现 pngnq 做得非常好。 它似乎是专门为创建带有 alpha 通道的 8 位 PNG 图像而设计的。
I also needed a Linux solution and found pngnq to do a pretty good job. It seems to be designed specifically for creating 8-bit PNG images with alpha channels.
对于 Mac:ImageOptim 和 ImageAlpha 是运行 pngcrush、pngquant 和各种其他通常命令行压缩实用程序的 GUI。 http://pngmini.com/
For Mac: ImageOptim and ImageAlpha are GUIs that run pngcrush, pngquant, and various other normally command-line compression utilities. http://pngmini.com/
您提供的链接引用了 ImageMagick,这是一个用于在 Linux 上操作图像的优秀工具包。
The link you provided references ImageMagick, which is an excellent toolkit for manipulating images on Linux.
啊,如果我没记错的话,当我几个月前读到这篇文章时,pngquant还没有Windows版本。 我看到现在已经有一个了 所以我尝试了,pngnq也尝试了。
后者似乎在 IceAlpha.png 测试图像(来自 libpng.org)上做得稍好一些,但代价是图像稍大(无论如何都可以使用 pngcrush 或 pngout 进行后处理)。
抖动算法(pngquant 的两种,pngnq 的唯一一种)是不同的,并且可能值得同时使用这两种工具,使用所有算法转换图像,然后看看哪种看起来最好。
根据记录,在 Windows 端,IrfanView (4.10) 可以很好地显示这些图像(使用每个调色板条目上的透明度级别),而 XnView (1.85.1) 和 GIMP (2.4) 仅应用完全透明/不透明显示,à la GIF:链接文章中作为示例给出的灯泡周围有透明背景,但橙色部分完全不透明。
优秀的实用程序 TweakPNG 显示我们有一个 PLTE(调色板,222 个条目)块和一个 tRNS(调色板颜色的 alpha 值,222 个条目)块。 更重要的是,它允许编辑每个调色板条目、颜色和 Alpha 级别。 它可能是这种格式的一个有趣的补充工具。
关于 IrfanView 支持的注意事项:如果它正确处理 PNG8 的透明度,则不会处理 PNG 文件中的伽玛信息:在巨嘴鸟图像或乒乓球图像上,我必须应用 2.4 的伽玛才能获得相似(更亮)的颜色。
另请注意,IrfanView 在将 32 位 PNG 图像转换为 256 位图像方面做得很糟糕,只允许一种透明颜色,如果全色抖动,这看起来很糟糕!
我看到 GIMP 手册 指出:“他的“PNG8”格式,如 GIF,仅使用一位透明度;仅可能有两种透明度级别:透明或不透明。”
而 ISO/W3C 标准规定:
“tRNS 块指定与调色板条目关联的 alpha 值(对于索引彩色图像)或单个透明颜色(对于灰度和真彩色图像)。”。 PNG 规范 1.2< /a> 补充道:“虽然简单的透明度不如完整的 Alpha 通道那么优雅,但它需要的存储空间更少,并且足以满足许多常见情况。”
看起来独特的透明颜色比完全透明调色板更容易实现,唉。 至少浏览器是正确的。
Ah, if I remember correctly, when I have read this article some months ago, pngquant hadn't a Windows version. I see it has one now. So I tried it, and pngnq too.
The latter seems to do a slightly better job on the IceAlpha.png test image (from libpng.org), at the cost of a slightly bigger image (it can be post-processed with pngcrush or pngout anyway).
The dithering algorithms (the two of pngquant, the only one of pngnq) are different, and it might be worth having both tools, converting images with all algorithms and see what looks the best.
For the record, on the Windows side, IrfanView (4.10) displays these images very well (using the transparency level on each palette entry) while XnView (1.85.1) and GIMP (2.4) apply only a full transparency/opaque display, à la GIF: the light bulb given as an example in the linked article has a transparent background around it, but the orange part is fully opaque.
And the excellent utility TweakPNG shows we have a PLTE (palette, 222 entries) chunk and a tRNS (alpha values for palette colors, 222 entries) chunk. Even more, it allows to edit each palette entry, color and alpha level. It might be an interesting complementary tool for this format.
Note on IrfanView support: if it handles PNG8 correctly for transparency, it doesn't handle gamma information in PNG files: on the toucan image or the ping-pong image, I had to apply a gamma of 2.4 to get similar (lighter) colors.
Note also that IrfanView does an awful job of converting 32-bit PNG images to 256, allowing only one transparent color, which looks bad if full color was dithered!
I see that the GIMP manual states: "his “PNG8” format, like GIF, uses only one bit for transparency; only two transparency levels are possible, transparent or opaque. "
while the ISO/W3C standard states:
"The tRNS chunk specifies either alpha values that are associated with palette entries (for indexed-colour images) or a single transparent colour (for greyscale and truecolour images).". The PNG specification 1.2 added: "Although simple transparency is not as elegant as the full alpha channel, it requires less storage space and is sufficient for many common cases."
It looks like the unique transparent color is more implemented than the full transparency palette, alas. At least browsers get it right.
这取决于您的原始图像到底是什么样子。
如果您的图像已包含 256 种或更少的颜色(RGBA 值),则只需查看 pngout (Windows) (Linux/BSD/Mac OS X ports),无论如何你应该已经使用它来优化你的 PNG 图像。 它不能量化图像,但可以将它们保存为 8 位,包括 Alpha 透明度。 只需传入
/c3
(或Linux 等上的 -c3
)颜色选项强制将图像保存为 PNG8。如果您的图像确实包含超过 256 种颜色,您还有更多选择,但都不太完美:
Adobe Fireworks 就生成的图像质量而言可能是最佳选择。 如果您只需要转换一些图像,或者您不介意依靠 Fireworks 进行批处理,那么它就可以完成这项工作。 我确实发现它有时会以某种方式限制调色板中的颜色数量,从而创建比必要的质量更差的图像。 我不知道这是否是 CS3 中的一个错误,但已在 CS4 中修复。
如果您使用的不是 Windows 或 OS X,这显然不是一个选择,并且仅仅为此购买 Fireworks 可能也不值得。
我知道的唯一替代方案是已经提到的 pngquant和 pngnq。 我在 pngnq 方面运气更好,但这可能取决于哪种量化策略最适合您正在使用的文件。
不幸的是,我注意到它们都不能很好地处理少量透明度(例如,带有透明圆角的不透明图像)。
It depends on what exactly your original images look like.
If your images already contain 256 or fewer colors (RGBA values), you need only look at pngout (Windows) (Linux/BSD/Mac OS X ports), which you should already be using to optimize your PNG images anyway. It can't quantize images, but it can save them as 8-bit, including alpha transparency. Just pass in the
/c3
(or-c3
on Linux et al.) color option to force it to save the image as PNG8.If your images do contain more than 256 colors, you have a few more, but all less than perfect options:
Adobe Fireworks is probably the best option in terms of the resulting image quality. It will do the job if you only need to convert a few images, or if you don't mind relying on Fireworks to do the batch processing. I did find that it sometimes somehow limits the number of colors in the palette, creating a worse quality image than necessary. I don't know if that's perhaps a bug in CS3 that's been fixed in CS4.
If you're not on Windows or OS X this obviously isn't an option, and buying Fireworks just for this probably isn't worth it either.
The only alternatives I know of are the already mentioned pngquant and pngnq. I've had better luck with pngnq, but that's probably just going to depend on which quantization strategy works best on the files you're working with.
Unfortunately, I've noticed that neither of them work very well with small amounts of transparency (say, an opaque image with transparent, rounded corners).
我推荐“The GIMP”,因为它可以以 PNG8 输出并支持Linux/Windows。 如果您想要一个快速的仅限 Windows 的解决方案,我还推荐 IrfanView。
I recommend "The GIMP" as it is possible to output in PNG8 and supports Linux/Windows. If you want a quick Windows-only solution, I also recommend IrfanView.
Microsoft Windows:Ultimate Paint(免费软件和共享软件
版本可用)。
两个版本都可以保存为 8 位透明 PNG 图像。
它还可以另存为 4 位 PNG(16 色)。 这削减了
与 8 位相比,文件大小减半。
输入格式包括 BMP、GIF、ICO、JPG/JPEG 和 PNG。
Ultimate Paint Standard 2.88 LE 的免费软件版本可以
可以直接从下载
http://www.ultimatepaint.com/up.zip (1.7 MB)。
Microsoft Windows: Ultimate Paint (freeware and shareware
versions are available).
Both versions can save as an 8 bit transparent PNG image.
It can also save as a 4 bit PNG (16 colours). This cuts the
file size in half compared to 8 bit.
Input formats include BMP, GIF, ICO, JPG/JPEG and PNG.
The freeware edition of Ultimate Paint Standard 2.88 LE can
be downloaded directly from
http://www.ultimatepaint.com/up.zip (1.7 MB).