我应该使用哪种格式的 png?
我应该使用 PNG 8 或 PNG 24 哪种格式的 PNG?哪一个更适合网站。我对这些很困惑。 PNG 8 和 PNG 2 之间的主要区别是什么?
Which format of PNG should I use PNG 8 or PNG 24? Which one is better for a website. I am confused about these. What is main different between PNG 8 and PNG 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
PNG-24。 Png-24 具有 alpha 透明度(其中 Png-8 仅具有开/关透明度)。
Png-8 已索引。 Png-24 是无损的。
Png-24 几乎在所有方面都更好。
http://www.elated.com/articles/understand-image-formats/< /a>
Png-24. Png-24 has alpha transparency (where Png-8 only has on/off transparency).
Png-8 is indexed. Png-24 is loss-less.
Png-24 is better in almost every way.
http://www.elated.com/articles/understanding-image-formats/
PNG 有多种可用模式。它可能包含:
索引颜色与其他颜色不同,它是最多 256 种颜色的调色板,其中索引用于表示特定像素的颜色。它可以通过辅助块包含透明度。因此,每个像素都由一个字节宽的值表示,如果调色板不是那么大,则甚至可以更小。如果您使用真彩色,每个像素将会有更多数据,具体取决于您是否使用 Alpha 通道。
因此,在大图像中,索引颜色将为每个像素节省大量数据。但是,如果使用超过 256 种颜色,一些颜色数据将会丢失,这在大图像中更可能发生。我建议以两种格式保存图像,看看损失是否值得以较小的文件大小获得。不过,如果您正在为普通网站而不是手机设计图像,那么无论如何您最好使用 PNG-24,因为没有人会注意到尺寸的差异。
PNG has several modes which can be used. It may contain:
Indexed colour is different from the others that it is a palette of maximum 256 colours, from which indexes are used to denote the colour of specific pixels. It can contain transparency via an auxillary chunk. So every pixel is denoted by a byte-wide value or even less if palette isn't that big. If you use truecolour, there will be more data per pixel, depending on whether you use an alpha-channel.
So in a large image indexed colour will save you a lot of data per each pixel. However, if you use more than 256 colours, some colour data will be lost, which is also more probable in a large image. I would advise to save your image in both formats and see if the loss is worth the gain in smaller file size. Though if you are designing your image for normal web site, not for mobile phones, you should better use PNG-24 anyway, since no one will notice the difference in the size.
我想说这取决于您想要存储为 PNG* 的图像,但如果您有疑问,PNG-24 更好:“真彩色”(每通道 8 位),因此图像不得抖动,并且不要“松散”“精确”颜色匹配,如果也带有 alpha 通道(透明度),也可以选择 PNG-32。 PNG-8 图像是有限的(从 24 位调色板中选择 256 种颜色)并且仅允许使用蒙版,例如,如果您从 GIF 图像转换,则可以使用它;如果您从其他“真彩色”格式进行转换,则会“失去”“精确”颜色匹配(程序尝试将使用的颜色的实际数量减少为仅 256 种颜色,并采用其他技巧来与原始颜色相似)。有些风格的图标不需要“真实颜色”,它们可以通过256种或更少的“固定”颜色很好地“描述”,所以PNG-8是可以的;如前所述,如果您有 GIF 图像作为源,请选择 PNG-8...如果您从 JPG 转换,请选择 PNG-24;如果您直接“在”PNG 中自己创建图像,您知道是否可以“压缩”PNG-8 中的结果,但如果您无法评估或使用工具来评估,则 PNG-24/32 是无论如何都可以。
I would say that it depends on the image you want to store as PNG*, but in case you've doubts, PNG-24 is better: "true color" (8bits per channel), so that the image must not be dithered and don't "loose" "exact" color match, and optionally PNG-32 if with the alpha channel (transparency) too. PNG-8 images are limited (256 colors chosen from a 24bit palette) and allow only for a mask, you can use it e.g. if you convert from a GIF image; if you convert from other "true color" formats, you "loose" "exact" color match as said (the program try to reduce the real number of used colors into only 256 colors, and other tricks to give resemblance with the original). Some style of icons do not need "true colors", they are "described" well by 256 "fixed" colors or less, and so PNG-8 is ok; as said, if you have GIF images as source, go for PNG-8... if you convert from JPG, go for PNG-24; if you create you image by yourself directly "in" PNG, you know if you can "crunch" the result in PNG-8 or not, but if you are not able to evaluate or use tools to evaluate, PNG-24/32 is ok in any case.
我写过关于它的文章:有效的 PNG,其中概述了所有主要PNG 的变体及其权衡/兼容性。
简而言之,尽可能使用 PNG8(调色板),因为它的文件大小要小得多。如果您使用好的工具,您可以在 PNG8 中拥有完全的 alpha 透明度(Photoshop 不适用于 PNG) )。
I've written article about it: PNG that works, which outlines all major variants of PNG and their trade-offs/compatibility.
In short, use PNG8 (paletted) whenever you can, as it has much smaller file size. You can have full alpha transparency in PNG8 if you use good tools (Photoshop is not good for PNG).