What is the difference between “JPG” / “JPEG” / “PNG” / “BMP” / “GIF” / “TIFF” Image?

前端 未结 11 1423
不知归路
不知归路 2020-12-02 04:12

I have seen many types of image extensions but have never understood the real differences between them. Are there any links out there that clearly explain their differences?

相关标签:
11条回答
  • 2020-12-02 05:01

    Yes. They are different file formats (and their file extensions).

    Wikipedia entries for each of the formats will give you quite a bit of information:

    • JPEG (or JPG, for the file extension; Joint Photographic Experts Group)
    • PNG (Portable Network Graphics)
    • BMP (Bitmap)
    • GIF (Graphics Interchange Format)
    • TIFF (or TIF, for the file extension; Tagged Image File Format)

    Image formats can be separated into three broad categories:

    • lossy compression,
    • lossless compression,
    • uncompressed,

    Uncompressed formats take up the most amount of data, but they are exact representations of the image. Bitmap formats such as BMP generally are uncompressed, although there also are compressed BMP files as well.

    Lossy compression formats are generally suited for photographs. It is not suited for illustrations, drawings and text, as compression artifacts from compressing the image will standout. Lossy compression, as its name implies, does not encode all the information of the file, so when it is recovered into an image, it will not be an exact representation of the original. However, it is able to compress images very effectively compared to lossless formats, as it discards certain information. A prime example of a lossy compression format is JPEG.

    Lossless compression formats are suited for illustrations, drawings, text and other material that would not look good when compressed with lossy compression. As the name implies, lossless compression will encode all the information from the original, so when the image is decompressed, it will be an exact representation of the original. As there is no loss of information in lossless compression, it is not able to achieve as high a compression as lossy compression, in most cases. Examples of lossless image compression is PNG and GIF. (GIF only allows 8-bit images.)

    TIFF and BMP are both "wrapper" formats, as the data inside can depend upon the compression technique that is used. It can contain both compressed and uncompressed images.

    When to use a certain image compression format really depends on what is being compressed.

    Related question: Ruthlessly compressing large images for the web

    0 讨论(0)
  • 2020-12-02 05:03

    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.

    With Indexed it means that the image can only store a limited number of colours (usually 256) that are chosen by the image author, with Direct it means that you can store many thousands of colours that have not been 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.

    BMP vs GIF


    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 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.

    GIF vs JPEG


    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.

    JPEG vs GIF


    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.

    PNG-8 vs GIF

    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, which 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!

    0 讨论(0)
  • 2020-12-02 05:08

    The file extension tells you how the image is saved. Some of those formats just save the bits as they are, some compress the image in different ways, including lossless and lossy methods. The Web can tell you, although I know some of the patient responders will outline them here.

    The web favors gif, jpg, and png, mostly. JPEG is the same (or very close) to jpg.

    0 讨论(0)
  • 2020-12-02 05:14

    Since others have covered the differences, I'll hit the uses.

    TIFF is usually used by scanners. It makes huge files and is not really used in applications.

    BMP is uncompressed and also makes huge files. It is also not really used in applications.

    GIF used to be all over the web but has fallen out of favor since it only supports a limited number of colors and is patented.

    JPG/JPEG is mainly used for anything that is photo quality, though not for text. The lossy compression used tends to mar sharp lines.

    PNG isn't as small as JPEG but is lossless so it's good for images with sharp lines. It's in common use on the web now.

    Personally, I usually use PNG everywhere I can. It's a good compromise between JPG and GIF.

    0 讨论(0)
  • 2020-12-02 05:15

    For the specified difference and usage between the varies of image formats have a good discussion above already.

    However, I want to add something for the overall process of capturing a picture and storing them.

    The capturing process

    Or you can say the construct process(as we can draw or make pictures with computers now). If you take a photograph with a camera, you are already using lots of sensors(CCD or CMOS) and algorithms(Bayer Pattern Filter, Sub-sampling and quantization, etc.) Also there are stuff like Pixel Format and Color Space. After you got the basic pixel information, there must be a way for storing them.

    The basic image file structure

    For storing the pixels info a file, we need a convention and related algorithms. For saving space, there are compression, but basically problem is encoding the pixels to bytes and decoding the bytes to pixels for display.

    A typical image file may be consisted by several parts, basically two:meta data or file header and pixel data section. The meta data tells about the image itself, maybe height and width, file format, etc. And the pixel data section is the real section who deals with the real picture.

    Storing and Displaying

    As we said earlier, files are stored in hard disk and are in bytes/bits. So image files have no priority but also bytes stream actually. For displaying, maybe we should get something to know how monitor works. Typical PC monitors use RGB model for displaying.

    Hope this helps:-)

    0 讨论(0)
提交回复
热议问题