View Full Version : Image Export Formats
03-09-2008, 07:07 PM
Table of Contents
Introduction to Image Formats
There are several common image formats we use in creating maps. The purpose of this thread is to examine each of those formats, explain their strengths and weaknesses, and try to give some guidelines on when to use each one.
First, there are two broad groups of formats: raster vs vector. A raster image is simply a grid of colored pixels (dots on your screen). Most images you see on the web are raster images, described by their resolution of horizontal and vertical pixels. The term "bitmap" is sometimes used interchangeably with raster. Raster images are defined by their resolution ( 800 X 600, for instance, meaning 800 pixels wide by 600 pixels tall ), and their color depth, or bit-depth. The color depth refers to how many possible colors there are in the image. I'll not go into the technical details of color depth here, but if you want further reading, try this article: http://www.luminous-landscape.com/tutorials/bit-depth.shtml
The other group of image formats are vector images. A vector graphic is described by mathematical formulae that the imaging software interprets and displays. Vector image formulas are continuous, so they are not limited by the resolution of the original picture. This means you can zoom in on a vector image and never see the ugly jaggies associated with increased magnification on a raster image. Unfortunately, web support for vector formats is limited, so although you can create images in a vector format, you will almost certainly have to export to a raster format if you want to share your work on the Internet. Many printshops can accept a variety of vector image formats, though, so if your target output is print, you can stay in vector from beginning to end if you so desire.
03-09-2008, 07:25 PM
Among the oldest image formats currently supported is Microsoft's Bitmap (bmp). The bitmap is very simple: it is simply the basic grid of colored dots with no compression. Because bitmaps are not compressed, they can get very large very quickly. For instance, an image with a resolution of 800 X 600 has 480,000 pixels. If it has 8 bits per pixel (256 colors possible), the file will be 480KB. That's one byte for every pixel. Suppose you want a 24-bit image, though? Your image shoots up to 1.44 MB. 800 X 600 is pretty small. If you're wanting a good-sized battle mat, say 24" X 36" at 200 dpi (dots per inch), you're talking about a resolution of 4800 X 7200. That's over 34 million pixels, and at 24 bits per pixel, you've got an image that requires more than 103 MB of memory just to load, to say nothing of emailing it to a friend for critiques.
The advantage to using the bitmap format is that it requires very little processing to manipulate an image. The computer is not forced to decode a compression scheme, so changes are very quick. That can be an advantage when dealing with complicated computations, although the processor speeds of most modern computers make the time savings minute.
Bitmaps are best used for small objects that are being prepared for extensive processing. The format does not support transparency, though, so its use is limited. Also, many internet browsers cannot natively display a bitmap. All in all, the bitmap format is largely obsolete, although it is still the default file format for MS Paint for some reason.
03-09-2008, 07:58 PM
In the early days of the Web, Compuserve's GIF format was everywhere. The GIF added three important things to imaging: compression, transparency, and animation.
Unlike the bitmap, GIF uses a compression scheme to reduce file sizes. GIF uses a lossless compression algorithm called Lempel-Ziv Welch (LZW), which looks for repeating horizontal patterns and stores each pattern only once. Every time the pattern is encountered in the image, it is replaced with a code that represents the longer pattern. In this way, GIFs compress by removing horizontal redundancy. GIF's compression is lossless, meaning that no information is discarded during the compression process, so the image will not lose quality if it is resaved.
GIF's second advantage over the bitmap is its ability to handle transparency. A GIF can have one color designated as transparent, allowing non-square images, and images with holes that let a background show through. However, since only one color can be made transparent, it is impossible to achieve anti-aliasing between a transparent graphic and the background it is placed on. Slanted lines or curves will show very obvious jagged edges.
The third thing GIF added was simple animation. A GIF can be built with several frames, and it will cycle through them endlessly to allow for very rudimentary motion graphics. Unfortunately, the LZW algorithm is not applied across the frames, so even though two frames may be similar, they are not compressed together. A ten-frame animation will be roughly 10 times larger than a single frame still.
All is not roses, though. GIF's maximum color depth is only 8 bits, so an image can have a maximum of 256 colors. Although that may seem like quite a lot, many colors are used to soften the jagged edges that appear on arcs and slanted lines. This anti-aliasing process can use far more colors than are allowed by the GIF format.
GIF is best used for images that have wide areas of solid color and simple geometric shapes. "Cartoony" images and text benefit the most from GIF compression. Text banners for web pages are often saved as GIFs because they allow a designer to use an unusual font, but they remain small enough to not add too much download time. Photographs and textured illustrations will receive almost no benefit from being saved as GIFs versus bitmaps. Also, the small color palette available with GIF means that a photograph will often lose quite a lot of color information, resulting in either ugly banding artifacts or very visible dithering.
03-09-2008, 08:14 PM
One of the most common image formats seen today is the jpeg. As its name implies, jpeg was invented for the benefit of digital photography. Like GIF, a jpeg uses compression to reduce file sizes. Unlike GIF, that is all it does; it has no additional features like transparency or animation.
Jpeg compression is a complex topic, and one that I have to admit I have not completely understood. Fortunately, the fundamentals of the topic are sufficient to know when to use jpeg over other formats. Jpeg is a lossy format; it discards information in order to reduce the file size. Jpeg compression removes some of the intermediate colors in a gradient, resulting in color "banding." At high levels of compression, this banding can become very noticeable, but at lower compression ratios, 50% or higher, the color loss is much less obvious. The compression also tends to add noise to solid-color areas of an image.
Because jpeg is a lossy algorithm, it is inadviseable to use it for anything other than final exports of an image. Each time a jpeg is resaved, a little more information is lost.
Jpeg is best used for the final export of a photographic or highly textured image. It does not do well with flat-colored artwork or sharp lines. Compressing text with jpeg will almost always produce blurry edges and obvious visual artifacts.
03-09-2008, 08:29 PM
The PNG format is a tremendous improvement over GIF. It generally compresses better, allows more colors, and it allows much more flexibility in transparency. It does not support animation, though.
PNG's compression algorithm is called Deflate. It is an improved version of LZW, and is the same algorithm used for zip archives. Where GIF compression looks at horizontal patterns, PNG is capable of also looking at vertical patterns, so it can compress an image even further than GIF.
A GIF image allows only 256 colors, but PNG supports up to 48 bits of color (16 bits per channel) and 16 more bits of transparency information. That's over 280 billion colors--far more than you're ever likely to need. It also allows for an alpha channel, which is a grayscale overlay that determines the level of transparency the image has. The alpha channel allows parts of the image to be translucent, and the edges to fade away. It also makes it possible to anti-alias the edges of a non-square image, eliminating the jagged edges.
The two most common varieties of PNG are PNG-8, which is an 8-bit palleted image very similar to a GIF, and PNG-24, which is a little bit of a misnomer, as it is 8 bits per channel. 24 bits for color, and 8 more for alpha, which means it is often actually a 32-bit image. Adobe (formerly Macromedia) Fireworks uses PNG as its native format, and a Fireworks PNG has a few extra features beyond the scope of this article. Some applications can open a Fireworks PNG, but those extra features will usually not be present.
Like GIF, png is best used for illustrative images with flat colors and sharp lines. It can also be used for textured or photographic images when transparency is needed, although it does not compress as well. Because it is a lossless format, it is possible to use it for working images without fear that they will lose quality after multiple saves.
03-09-2008, 10:01 PM
You can delete this post later if it gets in the way... but here's some rep for such a good post on image formats, you go mid! .. :D
03-09-2008, 10:10 PM
Thanks. It's pretty much finished now. If anyone notices any inaccuracies, please let me know. It's been quite some time since I learned this stuff, and I may have gotten some of it wrong. I haven't yet figured out how to approach the topic of vector images. If someone else gets inspired, go ahead and have a stab at it!
03-10-2008, 12:18 AM
OK, Bryan: this was amazingly helpful. In about four posts you explained concepts I've never understood (as a techno idiot, myself!) What a great idea and a great execution. Nicely done!
03-10-2008, 12:56 PM
Aliasing: Because a raster image is simply a grid of pixels, it is impossible to create a true slanted line or arc. The jaggedness seen at the edges of some images is called aliasing, and it is generally regarded as undesirable. However, if the number of colors available is limited, aliasing is unavoidable. See the image below for an example of aliasing.
Anti-aliasing: Anti-aliasing is a technique for reducing the jagged appearance of slanted lines and arcs. It blends the edges of such figures by adding intermediate colors, which fool the eye and make the edges appear smooth. This image shows how an aliased line is made to appear smoother through anti-aliasing:
Alpha Channel: There are two ways to achieve transparency in an image: Declare pixels of a certain color to be transparent, or add an additional channel of transparency information. This additional channel is called an alpha channel, and it can be used to make areas of an image partially or completely transparent. When separated from the rest of the image, an alpha channel appears to be a greyscale image. When this greyscale image is overlaid on the final image, areas that are black appear transparent, white areas are opaque, and grey areas are translucent, with the level of opacity determined by the value of the grey at that point. The image below illustrates an alpha channel. Notice how the background layer is invisible in the upper left and fully visible in the lower right and how that corresponds with the greyscale gradient. Alpha channels can also be used as selection tools in Photoshop, but that goes beyond the scope of this article. Here's a nice video tutorial for Photoshop: http://www.planetphotoshop.com/design-with-alpha-channel.html
Bit Depth: In a computer, every piece of information is described by binary code. One bit is a single "switch" that is either off or on: 0 or 1. So a one-bit pixel has only two values: Black or white. By adding bits, the amount of information that can be stored increases exponentially. A two-bit image can have four values: 00, 01, 10, 11. Each bit added multiplies the number of possible colors by two. Therefore, the bit depth of an image is directly tied to the number of colors the image can display. It is also directly tied to the size of the image file. More bits used to describe each pixel means more space is required to store it. It is common to refer to the total bit-depth of an image as bits per pixel or bits per channel. So 8 bits might refer to a paletted image with a maximum of 256 colors or to an image with 8 bits per channel and millions of possible colors.
There is also a distinction between integer and floating point numbers. I won't go into great detail here, but the basics are that integer numbers, regardless of depth, have a finite luminance range, running from black at 0 to white at whatever number is at the top of the scale. Floating point numbers run from black at 0 to white at 1, but they also permit negative numbers and values beyond 1. Visually, this doesn't make sense, but it opens some options for High Dynamic Range imaging (HDRi).
Channel: Each pixel in an image is described by numbers. In a 32-bit RGBA image, each pixel is described by four 8-bit numbers whose values ( 0 - 255 ) determine the color and transparency of that pixel. Each of these numbers represents a channel: red, green, blue, and alpha (transparency). The channels are a way of organizing information about the pixels so that they can be more easily manipulated. Each channel, if viewed by itself, will appear to be a greyscale image, with the brightness of a given pixel indicating the amount of that color present in the full image.
Color Depth: Color depth is the same as bit depth, except that it is a term more specific to graphics. When dealing with images, the two terms are mostly interchangeable.
Compression: Compression is a process that reduces the size of a file. Compression can be either "lossy" or "lossless." Lossy compression discards information, so it can achieve very small file sizes at the expense of accuracy. Lossless compression retains all of the original information, so there are limits to how small a file can be made.
CMYK: A color model that uses four values: cyan, magenta, yellow, and black. CMYK images do not display properly on a computer monitor, but they are ideal for printing. CMYK color mixing is subtractive: adding inks to the page causes fewer frequencies of light to be reflected, resulting in a darker color. Theoretically, equal quantities of cyan, magenta and yellow should produce black. Pigments are never perfect, though, so the result is typically dark brown instead, which is why black ink is added to the system. So-called "rich black" is produced by mixing a small amount of the colored inks with the black ink. The CMY primary hues are the complementary colors of the RGB primary hues. If you use curves to reduce the green in your RGB image, that is equivalent to boosting the magenta.
Dithering (http://en.wikipedia.org/wiki/Dither): A process where noise is added to an image to counteract banding artifacts from reducing its color space.
High Dynamic Range imaging (HDRi): A relatively new term in imaging, HDR is all about capturing more detail in images by reclaiming portions of the luminance range that normally fall outside of the limits of an image format. At the moment, it is primarily a topic for photographers, but as displays with greater bit-depth emerge (I have a 10-bit display at my workplace, and 12-bit displays are currently on the market) the limits of 8-bit per channel images are going to start making them obsolete. There are HDR variants of several of the image formats detailed here, but OpenEXR looks like it will be the format of the future. For more information on this topic, I recommend consulting the blog of my friend Christian Bloch: HDR Labs. (www.hdrlabs.com) And if you're interested in even deeper coverage, he wrote the book on the topic: The HDRI Handbook 2.0, available on Amazon.
Paletted Image: An image for which the colors are preselected and stored in a table in the file rather than having color channels. Paletted images are frequently much smaller than images that use channels, but they are more difficult to work with. A paletted image is often temporarily converted to RGB when it is being edited, and the palette is reconstructed upon saving. Although most software does a good job of selecting a palette, some images might benefit from the user making a couple of decisions while saving to minimize file size.
Pixel: A single "dot" on a computer screen. A raster image is composed of a grid of pixels, each with its own color information.
Resolution: The number of pixels present in an image or computer display. Resolution is described with two numbers: the first is the number of horizontal dots (columns) and the second is the number of vertical dots (rows). 800 X 600 means 800 pixels wide by 600 pixels tall. This is distinct from the print resolution, which is described by the number of dots the printer places in a linear inch. The unit of print resolution is dots per inch (dpi), and in terms of image size, it is meaningless unless accompanied by the physical dimensions of the printed piece, measured in inches. So 300 dpi at 8"x10" is a useful description. The screen resolution of an image may be found by multiplying the horizontal and vertical measurements by the dpi. The screen resolution of the example is therefore 2400 x 3000 pixels (8 * 300 x 10 * 300).
RGB: A color model that uses three values: red, green and blue. RGB images must be converted to CMYK prior to being printed, but they display correctly on a computer monitor. RGB color mixing is additive: adding light to the spectrum causes more frequencies to be perceived by the eye, resulting in a brighter color. The RGB primary hues are complementary to the CMY primary hues. If you need less yellow in your RGB image, increase the blue.
03-10-2008, 03:38 PM
Very good.. rep,rep,rep...
03-11-2008, 12:31 PM
Might want to add the .psd format. It is something of a standard now (layering being its primary advantage). Also, TIFF is still used for a lot of things.
It's probably worth adding vector formats to the list. I use vector art quite a bit, but am no expert on the various formats. Breifly, I know the following:
To restate information in the original post: what have been previously described are "raster" formats. This means, basically, that the image is stored (or, at least conceived) as a grid of pixels. The disadvantage is that, well, it's a grid of pixels. Even though the image might look like a particular object, you can't actually manipulate it as one, because it's really just part of a pixel grid. (So, you need to rely on tools and tircks to "extract" just the pixels you want, and so on.) Also, while such images can be made smaller without loss of quality, making them larger results in "jaggies". File sizes also can get very large.
In contrast, "vector" formats describe an image using mathematical paths. This has the advantage that it can be drawn at any resolution (bigger or smaller) without losing quality. Also, the paths can be manipulated as paths, not as pixel grids. So, that thing that looks like a box really is a box that can be independently edited without weird pixel selection tricks. Disadvantages include a more "sharp" look and an inability to do some of the things you can do with pixels (e.g. smudging, some kinds of filtering, etc.) Most vector formats can also embed raster images (i.e. rectangles filled with a particular pixel grid) inside them.
Scaled Vector Graphics (http://en.wikipedia.org/wiki/SVG) (SVG) - An XML-based standard for vector images. It is supposedly cross platform, but there appear to be a lot of differences between the implementations, as far as I can tell. This may be improving now. SVG can also support time-based modifications (i.e. animation).
SVGZ - Since SVG files are XML, they compress well, so are often zipped. When an SVG is zipped, the result is a SVGZ file.
Encapsulated Post Script (http://en.wikipedia.org/wiki/Encapsulated_PostScript) (EPS) - PostScript (a language used in printers) is a series of drawing instructions. The EPS concept is sort of a way to wrap little snippets of PostScript code into budles that can be used as embeddable images. For a long time this was (and may still be) the standard for distributing vector content. There are/were a number of different "flavors" of EPS for a while, and lots of different EPS interpreters (with widely varying degrees of quality). So, while the format is cross-platform, there are occasional gotchas with moving files.
Portable Document Format (http://en.wikipedia.org/wiki/Portable_Document_Format) (PDF) - Sort of the evolution of EPS, PDF is much more advanced and built with a different purpose in mind. Meant to represent paginated documents, PDF can also be used as just a graphics format. Like EPS, it consists of a series of PostScript instructions. Though most people don't use PDFs as graphics, they are capable of preserving layers and object characteristics. As an example, a PDF saved by Adobe Illustrator can usually be opened back up in Illustrator, preserving nearly all of the original Illustrator file characteristics (although, this appears to be done by just embedding the Illustrator format as an unrendered blob in the PDF). PDFs have a lot of font-based options, unlike some vector formats, allowing text to render as the creator intended, even if the consumer doesn't have that font installed.
Adobe Illustrator Artwork (http://en.wikipedia.org/wiki/Adobe_Illustrator_Artwork) (AI) - Since crushing its most serious rival (Freehand), Illustrator has become the king-daddy vector drawing package, and so its file format is often used to distribute vector content (particularly in the clip art world). Originally based on EPS, it has evolved significantly.
Shockwave Flash (http://en.wikipedia.org/wiki/SWF) (SWF) - A vector format focusing on animation and (these days) interactive elements. It's primary use for cartography is that it is the most reliable way of delivering cross-platform, resolution independent, zoomable maps to the web. Drawbacks include the fact that most people hate it.
PICT and WMF - Files containing a collection of drawing instructions, using a platform specific drawing system. PICTs are a Mac format, based on QuickDraw. Windows Metafiles (WMF) are a Windows format, based on the Windows GDI. These files are not at all compatible, but many converters exist to change one into the other. These formats used to be fairly common, but I don't see them used much any more.
03-11-2008, 03:34 PM
Nice add-on, Wordman! (Good to see you posting again too, btw!)
06-17-2011, 11:02 PM
TIFF is a raster "wrapper." Strictly speaking, it isn't a format, but a container that can hold several different formats of data. It is protected by a copyright currently owned by Adobe Systems, and it has never been fully standardized. As a result, some programs handle it differently than others, and there are occasions when a tiff written on one computer or by one application cannot be read by another. I have personally run into problems moving tiffs from PC to Mac installations of Photoshop, and also from my compositing software (Nuke) to Adobe Premiere on the same computer.
Advantages of TIFF include its ability to hold layer information, much like a Photoshop document, and multiple alpha channels. Many applications will misinterpret the additional channels, though, and there is really no way to know which channel will be selected as transparency, so it is advisable to include only a single alpha in a tiff intended for display. Some extensions to the Tiff format include support for high bit-depth images, up to 32 bits per channel (96 or even 128 bits per pixel), CMYK color, or even YCbCr (YUV) color.
Available compression algorithms that can typically be applied to a tiff include LZW, DEFLATE, and RLE. None of these do particularly well with photographic data; no better than PNG, really. As a result, there is not really any reason to choose tiff as a final export format over PNG. Tiff's flexibility is useful, but ultimately limits it as a format for interchange between artists and systems.
06-17-2011, 11:14 PM
Around the same time that TIFF was being developed, Truevision was developing another similar format for digital video applications. Truevision was eventually purchased by Avid Technology, which continues to support the format in its video editing software. Unlike TIFF, TGA is unencumbered by copyright or patents, making it a somewhat safer format.
Targa is technically inferior to tiff because it lacks support for layering and can use only one type of compression (RLE). Its advantages, though, are inherent in that simplicity; every application and system that supports TGA will render it the same way, making it very popular still in video production pipelines. It supports a standardized alpha channel that most applications will interpret properly as a transparency channel. In addition to digital video, Targa is also popular in video gaming, where it is frequently used for texture maps.
TGA's maximum color depth is 32 bits per pixel: three 8-bit channels for RGB and another 8-bit alpha. Use TGA when you need lossless compression, transparency, and wide compatibility.
06-17-2011, 11:43 PM
OpenEXR is a fairly new format developed for High Dynamic Range imagery (HDRi) by Industrial Light and Magic (ILM). It was created to streamline visual effects work in a number of ways.
First, it can use several different kinds of compression, both lossy and lossless, for efficiency with a variety of different kinds of data. One particularly useful compression algorithm is called PIZ, which is very good at compressing grainy images.
Second, it permits several different bit depths, including 32-bit integer and 32-bit floating point.
Third, with high bit-depths comes the ability to store and work with linear light information. Most digital images have a gamma correction applied that expands the color space where the human eye is most sensitive and reduces color space in ranges where it is less sensitive. While this makes the images look better when displayed, it really futzes with the math during image processing. A discussion of gamma and linear workflows is a bit beyond the scope of this post, so I'll leave it at that. For more information on that topic, I recommend this article: http://mymentalray.com/wiki/index.php/Gamma
Fourth, it has a theoretically unlimited number of available channels, each of which is (ideally) tagged with its purpose. In addition to an alpha for transparency, an OpenEXR file can also contain channels serving a variety of different purposes. In visual effects, this is commonly used to store multiple render passes of 3d objects in a single file, so a compositor only needs one image sequence instead of a dozen (or more). Also, certain utility channels can be generated, such as a z-depth channel that can be used to create depth of field or atmospheric perspective tricks during post-processing.
Fifth, it is an open source format available under a free license, which encourages developers to create tools to make use of it.
OpenEXR has its downsides, though. Pulling an arbitrary number of channels out of a single file tends to be slower than using multiple files, particularly when some of those channels may not even ultimately be used. It is also not well supported in all applications yet. Software that sees a lot of use in the film industry uses it, but other applications have been slower to adopt it. Most users will never have the need to use the high bit-depth available from OpenEXR, and even fewer will ever need more than four channels. So there is a lot of added complexity with very little benefit. That may change over time, as people come up with more reasons to use those extra channels, but I expect it will be many years before end users are swapping files with a .exr extension.
06-18-2011, 07:50 AM
Thanks for sharing such a useful information.
02-07-2013, 03:14 PM
The Photoshop Document format is not an export format, so I have put off detailing it. I've learned a little bit about it recently, though, so I thought I'd throw it in here.
PSD, as its name suggests, is the internal file format used by Adobe Photoshop. Because Photoshop is so widely used, PSD files can often be read by other software, although few other programs will access all of its features. This compatibility is helped along by PSD's structure, which is a modified form of TIFF. The largest difference between the two is the lack of adjustment layers in TIFF.
The related PSB (PhotoShop Big) format is intended for Photoshop documents that exceed 2 GB in file size and/or 30,000 pixels in resolution (horizontal or vertical). I believe that it also has provisions for images with 32-bit float channels, to permit High Dynamic Range (HDR) imagery. I am relatively new to HDR topics, though, so I don't know all of the details there. Anyone who does is welcome to chime in. PSB does have a limit of 300,000 x 300,000 pixels, but no file size limit that I am aware of (except that imposed by the file system, of course).
- Max -
02-07-2013, 03:18 PM
Btw PSB is for files up to 2 GB ;)
02-07-2013, 04:36 PM
Hmm… I thought the limit on a PSD was 4 GB, but that may well be a theoretical limit rather than a practical one. I'll look into that and update accordingly.
edit: I had it confused with the ~4 GB limit on files under the Fat32 file system.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.