Html png8和png24有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22707130/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is difference between png8 and png24
提问by Kesar Sisodiya
I want to know about uses of png files. There are two formats available for png images; one is png8and the another one is png24.
我想了解 png 文件的用途。png 图像有两种格式;一个是png8,另一个是png24。
I would like to know that if I use either type in my html
page, will there be any error? Or is this only quality matter?
我想知道如果我在我的html
页面中使用任何一种类型,会不会有任何错误?还是这只是质量问题?
回答by user694733
There is only one PNG format, but it supports 5 color types.
只有一种 PNG 格式,但它支持5 种颜色类型。
PNG-8 refers to palette variant, which supports only 256 colors, but is usually smaller in size. PNG-8 can be a GIF substitute.
PNG-8 是指调色板变体,仅支持 256 种颜色,但通常尺寸较小。PNG-8 可以是 GIF 的替代品。
PNG-24 refers to true color variant, which supports more colors, but might be bigger. PNG-24 can be used instead of JPEG, if lossless image format is needed.
PNG-24 是指真彩色变体,支持更多颜色,但可能更大。如果需要无损图像格式,可以使用 PNG-24 代替 JPEG。
Any modern web browser will support both variants.
任何现代 Web 浏览器都将支持这两种变体。
回答by Mehar
From the Web Designer's Guide to PNG Image Format
PNG-8 and PNG-24
There are two PNG formats: PNG-8 and PNG-24. The numbers are shorthand for saying "8-bit PNG" or "24-bit PNG." Not to get too much into technicalities — because as a web designer, you probably don't care — 8-bit PNGs mean that the image is 8 bits per pixel, while 24-bit PNGs mean 24 bits per pixel.
To sum up the difference in plain English: Let's just say PNG-24 can handle a lot more color and is good for complex images with lots of color such as photographs (just like JPEG), while PNG-8 is more optimized for things with simple colors, such as logos and user interface elements like icons and buttons.
Another difference is that PNG-24 natively supports alpha transparency, which is good for transparent backgrounds. This difference is not 100% true because Adobe products' Save for Web command allows PNG-8 with alpha transparency.
PNG-8 和 PNG-24
有两种 PNG 格式:PNG-8 和 PNG-24。这些数字是表示“8 位 PNG”或“24 位 PNG”的简写。不要过多讨论技术问题——因为作为一名网页设计师,你可能并不关心——8 位 PNG 意味着图像是每像素 8 位,而 24 位 PNG 意味着每像素 24 位。
用简单的英语总结一下区别:我们只是说 PNG-24 可以处理更多颜色,并且适用于具有大量颜色的复杂图像,例如照片(就像 JPEG),而 PNG-8 更适合具有简单的颜色,例如徽标和用户界面元素,例如图标和按钮。
另一个区别是 PNG-24 本身支持 alpha 透明度,这对透明背景很有用。这种差异并非 100% 正确,因为 Adobe 产品的 Save for Web 命令允许具有 alpha 透明度的 PNG-8。
回答by Glenn Randers-Pehrson
You have asked two questions, one in the title about the difference between PNG8 and PNG24, which has received a few answers, namely that PNG24 has 8-bit red, green, and blue channels, and PNG-8 has a single 8-bit index into a palette. Naturally, PNG24 usually has a larger filesize than PNG8. Furthermore, PNG8 usually means that it is opaque or has only binary transparency (like GIF); it's defined that way in ImageMagick/GraphicsMagick.
你问了两个问题,一个在标题中关于PNG8和PNG24的区别,已经收到了一些答案,即PNG24有8位红绿蓝通道,PNG-8只有一个8位索引到调色板中。自然地,PNG24 通常比 PNG8 具有更大的文件大小。此外,PNG8 通常意味着它是不透明的或只有二进制透明度(如 GIF);它在 ImageMagick/GraphicsMagick 中是这样定义的。
This is an answer to the other one, "I would like to know that if I use either type in my html page, will there be any error? Or is this only quality matter?"
这是对另一个的回答,“我想知道,如果我在我的 html 页面中使用任何一种类型,会不会有任何错误?或者这只是质量问题?”
You can put either type on an HTML page and no, this won't cause an error; the files should all be named with the ".png" extension and referred to that way in your HTML. Years ago, early versions of Internet Explorer would not handle PNG with an alpha channel (PNG32) or indexed-color PNG with translucent pixels properly, so it was useful to convert such images to PNG8 (indexed-color with binary transparency conveyed via a PNG tRNS chunk) -- but still use the .png extension, to be sure they would display properly on IE. I think PNG24 was always OK on Internet Explorer because PNG24 is either opaque or has GIF-like single-color transparency conveyed via a PNG tRNS chunk.
您可以在 HTML 页面上放置任何一种类型,不,这不会导致错误;这些文件都应该以“.png”扩展名命名,并在您的 HTML 中以这种方式引用。多年前,早期版本的 Internet Explorer 无法正确处理带有 alpha 通道 (PNG32) 的 PNG 或带有半透明像素的索引颜色 PNG,因此将此类图像转换为 PNG8(通过 PNG 传输的二进制透明度的索引颜色)很有用tRNS 块)——但仍使用 .png 扩展名,以确保它们能在 IE 上正确显示。我认为 PNG24 在 Internet Explorer 上总是可以的,因为 PNG24 要么不透明,要么具有通过 PNG tRNS 块传达的类似 GIF 的单色透明度。
The names PNG8 and PNG24 aren't mentioned in the PNG specification, which simply calls them all "PNG". Other names, invented by others, include
PNG 规范中没有提到名称 PNG8 和 PNG24,只是将它们统称为“PNG”。由他人发明的其他名称包括
- PNG8 or PNG-8 (indexed-color with 8-bit samples, usually means opaque or with GIF-like, binary transparency, but sometimes includes translucency)
- PNG24 or PNG-24 (RGB with 8-bit samples, may have GIF-like transparency via tRNS)
- PNG32 (RGBA with 8-bit samples, opaque, transparent, or translucent)
- PNG48 (Like PNG24 but with 16-bit R,G,B samples)
- PNG64 (like PNG32 but with 16-bit R,G,B,A samples)
- PNG8 或 PNG-8(带有 8 位样本的索引颜色,通常意味着不透明或具有类似 GIF 的二进制透明度,但有时包括半透明)
- PNG24 或 PNG-24(具有 8 位样本的 RGB,可能通过 tRNS 具有类似 GIF 的透明度)
- PNG32(带有 8 位样本的 RGBA,不透明、透明或半透明)
- PNG48(与 PNG24 类似,但具有 16 位 R、G、B 样本)
- PNG64(与 PNG32 类似,但具有 16 位 R、G、B、A 样本)
There are many more possible combinations including grayscale with 1, 2, 4, 8, or 16-bit samples and indexed PNG with 1, 2, or 4-bit samples (and any of those with transparent or translucent pixels), but those don't have special names.
还有更多可能的组合,包括具有 1、2、4、8 或 16 位样本的灰度和具有 1、2 或 4 位样本的索引 PNG(以及具有透明或半透明像素的任何一种),但那些不没有特殊的名字。
回答by richa_pandey
Basic difference : a 8-bit PNG comprises a max. of 256 colors. PNG-24 is a loss-less format and can contain up to 16 million colors.
基本区别:8 位 PNG 包含一个最大值。256 种颜色。PNG-24 是一种无损格式,可以包含多达 1600 万种颜色。
Impacts:
影响:
- If you are using any round corner image then edges might visible in png8 format.
- ie6 doesnt support png24 format.
- 如果您使用的是任何圆角图像,则边缘可能以 png8 格式可见。
- ie6 不支持 png24 格式。
回答by richa_pandey
The main difference is that a 8-bit PNG comprises a max. of 256 colours, like GIFs. PNG-24 is a lossless format and can contain up to 16 million colours.
主要区别在于 8 位 PNG 包含一个最大值。256 种颜色,如 GIF。PNG-24 是一种无损格式,可以包含多达 1600 万种颜色。
回答by rajessh
While making image with fully transparent background in PNG-8, the outline of the image looks prominent with little white bits. But in PNG-24 the outline is gone and looks perfect. Transparency in PNG-24 is greater and cleaner than PNG-8.
用PNG-8制作背景全透明的图像时,图像的轮廓看起来很突出,有一些白点。但是在 PNG-24 中,轮廓消失了,看起来很完美。PNG-24 的透明度比 PNG-8 更大、更清晰。
PNG-8 contains 256 colors, while PNG-24 contains 16 million colors.
PNG-8 包含 256 种颜色,而 PNG-24 包含 1600 万种颜色。
File size is almost double in PNG-24 than PNG-8.
PNG-24 的文件大小几乎是 PNG-8 的两倍。