Which pixel image file format to use?
There are so many pixel image file formats, which one should you use?
If you are free to choose the file format yourself, here are some things to be considered.
- Popularity - use a well-known standard file format if possible.
Proprietary solutions sometimes beat the popular file formats in terms of speed or
compression ratio, but unless there is a huge difference, don't bother to deal with
something that nobody else supports.
- Image type - note that some combinations of file format and compression
algorithm are suitable for specific image types only.
JPEG is for photos, GIF for graphics with few distinct colors, TIFF Group 4 for fax-like
black and white images. Deflate (as used in PNG) is a good general purpose compression
algorithm. Even if you're willing to accept inferior compression performance, some
file formats do not support certain image types at all (no truecolor in GIF, no bilevel [black
and white] in JPEG, and so on).
- Beware of lossy compression - file formats with lossy compression (like JPEG)
are able to create very small files by dropping some of the image information.
If this is done repeatedly, more information (=image quality) may get lost than you
really want. So saving as JPEG should be a one-time, final step after all image
editing was done.
- CPU requirements - if you repeatedly save an image (as you would in an editor), you
don't want saving to take forever, especially in an interactive setting.
So instead of using PNG with maximum compression every time,
maybe it's enough to use it as the final step and save the image without any compression
while editing.
- Transparency information - file formats also differ in how they support transparency.
Some formats know alpha channels (transparency information per pixel, e.g. TIFF or PNG),
some formats have a transparency index, a single color that is considered transparent (e.g. GIF
or PNG), some don't know the concept at all (JPEG). If you have to compose images, this might
be important for you. As a workaround, you could store an alpha channel in a separate file.
- Costs - some file formats like GIF use patented algorithms, so you must pay a
license fee to use them.
Consider free alternatives (like PNG) unless you really need a specific file format.
When you have to decide whether to use a free or commercial toolkit, keep in mind that buying a stable,
tuned commercial toolkit with support may save you a lot of time and be worth the money.