BMP vs GIF vs JPG vs JPEG vs PNG-8 vs PNG-24

原文:http://stackoverflow.com/questions/2336522/png-vs-gif-vs-jpeg-when-best-to-use

You should be aware of a few key factors...

First, there are two types of compression: Lossless and Lossy.

  • Lossless means that the image is made smaller, but at no detriment to the quality.
  • Lossy means the image is made (even) smaller, but at a detriment to the quality. If you saved an image in a Lossy format over and over, the image quality would get progressively worse and worse.

There are also different colour depths (palettes): Indexed color and Direct color.

  • Indexed means that the image can only store a limited number of colours (usually 256), controlled by the author, in something called a Color Map
  • Direct means that you can store many thousands of colours that have not been directly chosen by the author


BMP - Lossless / Indexed and Direct

This is an old format. It is Lossless (no image data is lost on save) but there‘s also little to no compression at all, meaning saving as BMP results in VERY large file sizes. It can have palettes of both Indexed and Direct, but that‘s a small consolation. The file sizes are so unnecessarily large that nobody ever really uses this format.

Good for: Nothing really. There isn‘t anything BMP excels at, or isn‘t done better by other formats.



GIF - Lossless / Indexed only

GIF uses lossless compression, meaning that you can save the image over and over and never lose any data. The file sizes are much smaller than BMP, because good compression is actually used, but it can only store an Indexed palette. This means that for most use cases, there can only be a maximum of 256 different colours in the file. That sounds like quite a small amount, and it is.

GIF images can also be animated and have transparency.

Good for: Logos, line drawings, and other simple images that need to be small. Only really used for websites.



JPEG - Lossy / Direct

JPEGs images were designed to make detailed photographic images as small as possible by removing information that the human eye won‘t notice. As a result it‘s a Lossy format, and saving the same file over and over will result in more data being lost over time. It has a palette of thousands of colours and so is great for photographs, but the lossy compression means it‘s bad for logos and line drawings: Not only will they look fuzzy, but such images will also have a larger file-size compared to GIFs!

Good for: Photographs. Also, gradients.

Nothing; JPEG is a type of image compression which has multiple file extensions associated with it.

The reason to have .jpg after .jpeg exists is that for MS-DOS and FAT-16 file systems there is a very limiting restriction on directories and filenames: 8 characters with 3 characters for the extension. Thus .jpeg is also seen as .jpg (and as .jpe and .jif).



PNG-8 - Lossless / Indexed

PNG is a newer format, and PNG-8 (the indexed version of PNG) is really a good replacement for GIFs. Sadly, however, it has a few drawbacks: Firstly it cannot support animation like GIF can (well it can, but only Firefox seems to support it, unlike GIF animation which is supported by every browser). Secondly it has some support issues with older browsers like IE6. Thirdly, important software like Photoshop have very poor implementation of the format. (Damn you, Adobe!) PNG-8 can only store 256 colours, like GIFs.

Good for: The main thing that PNG-8 does better than GIFs is having support for Alpha Transparency.

Important Note: Photoshop does not support Alpha Transparency for PNG-8 files. (Damn you, Photoshop!) There are ways to convert Photoshop PNG-24 to PNG-8 files while retaining their transparency, though. One method is PNGQuant, another is to save your files with Fireworks.



PNG-24 - Lossless / Direct

PNG-24 is a great format that combines Lossless encoding with Direct color (thousands of colours, just like JPEG). It‘s very much like BMP in that regard, except that PNG actually compresses images, so it results in much smaller files. Unfortunately PNG-24 files will still be much bigger than JPEGs, GIFs and PNG-8s, so you still need to consider if you really want to use one.

Even though PNG-24s allow thousands of colours while having compression, they are not intended to replace JPEG images. A photograph saved as a PNG-24 will likely be at least 5 times larger than a equivalent JPEG image, with very little improvement in visible quality. (Of course, this may be a desirable outcome if you‘re not concerned about filesize, and want to get the best quality image you can.)

Just like PNG-8, PNG-24 supports alpha-transparency, too.

I hope that helps!

时间: 2024-10-05 22:44:28

BMP vs GIF vs JPG vs JPEG vs PNG-8 vs PNG-24的相关文章

应用libjpeg提取jpeg质量因子

http://blog.csdn.net/lzhq28/article/details/7775222 版权声明:本文为博主原创文章,未经博主允许不得转载. [cpp] view plain copy print? data = new BYTE [cinfo.image_width*cinfo.image_height*cinfo.num_components]; 基本思路:利用开源库实现对jpeg的解压缩以直接提取量化表,根据标准量化表和所提取量化表编写算法实现质量因子的求算. 步骤一:使用

LISTVIEW显示JPEG缩略图

http://www.ctsys.cn/files/SHOW_FILES.ASPX?ID=22 许多的JPEG图片浏览器(如由我设计的<JPEG浏览缩放器>),都可以将JPEG缩略图放置到Listview控件中,实现图片的预览.要在Listview上显示图片,Listview控件必须与Imagelist控件关联,先将图片装入到IMAGELIST控件中,再通过这种方式对应: Listview1.Item[0].ImageIndex=3 但是Imagelist控件仅支持BMP和ICO格式,而且装载

vc++ mfc 里保存缩放的bmp图片 不失真

void CSaveView::OnFileSave() { BITMAP info;//原始图片 m_bitmap.GetBitmap(&info); CDC DC1; DC1.CreateCompatibleDC(NULL); DC1.SelectObject(&m_bitmap); DC1.MoveTo(0,0); DC1.LineTo(info.bmWidth,info.bmHeight); CDC DC2; CBitmap bmp;//缩放后的图片 bmp.CreateCompa

sqlserver字段类型

bit    整型 bit数据类型是整型,其值只能是0.1或空值.这种数据类型用于存储只有两种可能值的数据,如Yes 或No.True 或False .On 或Off. 注意:很省空间的一种数据类型,如果能够满足需求应该尽量多用. tinyint   整型 tinyint 数据类型能存储从0到255 之间的整数.它在你只打算存储有限数目的数值时很有用.这种数据类型在数据库中占用1 个字节. 注意:如果bit类型太单调不能满足您的需求,您可以考虑用tinyint类型,因为这个类型相对也是比较安全的

ASP.NET内核几大对象、ASP.NET核心知识(7)--转载

本文的学习流程是这样安排的. 一个简单的GDI小案例 1.说明 如果你想思考如何生成验证码,那么您第一个要解决的问题,一定是.NET动态生成图片问题. //GDI:.Net程序中进行绘图的一些类. 2.代码 1 //这段代码开始前,要添加System.Drawing的引用. 2 //创建一个尺寸为500*500的内存图片 3 using (Bitmap bmp = new Bitmap(500, 500)) 4 //得到图片的画布 5 using (Graphics g = Graphics.F

Struts2单文件上传原理及示例

一.文件上传的原理 表单元素的enctype属性指定的是表单数据的编码方式,该属性有3个值: 1.application/x-www-form-urlencoded:这是默认编码方式,它只处理表单域里的value属性值,采用这种编码方式的表单会将表单域的值处理成URL编码方式. 2.multipart/form-data:这种编码方式的表单会以二进制流的方式来处理表单数据,这种编码方式会把文件域指定文件的内容也封装到请求参数里. 3.text/plain:这种方式主要适用于直接通过表单发送邮件的

Struts2拦截器之FileUploadInterceptor

一.它能做什么? 借助于这个拦截器我们可以实现文件的上传和下载功能. 理论部分: struts2的文件上传下载功能也要依赖于Apache commons-fileupload和Apache commons-io两个开源项目,要使用上传功能就需要把它们引入到classpath中. 比如考虑上传文件,几个关键点就是可以传什么类型的文件?可以传多大的文件?传过来以后放哪儿?叫什么名字? 当文件上传过来的时候是放在一个临时目录里的,我们在Action中持有一个成员属性File,这个File指向的就是服务

C#使用tesseract3.02识别验证码模拟登录

一.前言 使用tesseract3.02识别有验证码的网站 安装tesseract3.02 在VS nuget 搜索Tesseract即可. 二.项目结构图 三.项目主要代码 1 using System; 2 using System.Collections.Concurrent; 3 using System.Collections.Generic; 4 using System.Diagnostics; 5 using System.Drawing; 6 using System.IO;

MsSQL的字段类型--(转载)

转载:http://www.cnblogs.com/skylaugh/archive/2006/07/31/464107.html 数据类型是数据的一种属性,表示数据所表示信息的类型.任何一种计算机语言都定义了自己的数据类型.当然,不同的程序语言都具有不同的特点,所定义的数据类型的各类和名称都或多或少有些不同.SQLServer提供了25种数据类型: ·Binary[(n)] ·Varbinary[(n)] ·Char[(n)] ·Varchar[(n)] ·Nchar[(n)] ·Nvarch