The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly.



Paint Shop Pro

Jasc's Paint Shop Pro 5.0 is a capable and popular program for image editing; it is also quite affordable. Version 5.0 supports only 32-bit Windows, but version 3.12 is still available for Windows 3.x and NT 3.51 and also supports PNG. We'll only be looking at the newer release, however.

At the most basic level, PSP supports the three major PNG image types: colormapped, grayscale, and RGB, both interlaced and noninterlaced. It provides options for converting between types, but it does not do so automatically; if a ``16-million-color'' image happens to use only 200 colors, it will still be saved as 24-bit RGB unless the user specifically asks for conversion to a palette image. Both GIF-style transparency (one completely transparent palette entry) and full 32-bit RGBA are supported, but RGBA-palette mode is not.

Paint Shop Pro's interface for adding an alpha mask to an image is quite elegant. First, open an ordinary RGB image, then pop up the Add Mask From Image dialog box, shown in Figure 4-8:

  1. Choose FileOpen.

  2. Choose MaskNewFrom Image.

  3. Choose MaskEdit.

The second step brings up the dialog box, shown in Figure 4-8. Setting the source to This Window guarantees that the size is correct, and basing it on the Source Opacity, where the original image had no transparency at all, will produce a blank slate on which gradients and other fills can be placed. Choosing the Source luminance button instead will generate transparency according to the light and dark areas in the image itself, and the areas that are considered transparent can be inverted by checking the Invert mask data checkbox at the bottom. Either way, the mask can be edited as an ordinary grayscale image after the third step.

Figure 4-8

Figure 4-8: Paint Shop Pro alpha mask window.

Saving such an image is a two-step procedure. First, the alpha mask must be ``glued'' to the main image as its alpha channel, after which the standard save procedure applies:

  1. Choose MaskSave To Alpha Channel.

  2. Choose FileSave As (or Save Copy As).

Converting an existing truecolor image to palette-based or creating a new palette-based image involves essentially the same procedure:

  1. Choose FileOpen or New.

  2. Choose ColorsDecrease Color Depth256 Colors.

Other depths are available, but most create the same size palette; indeed, the only other supported palette sizes in the output file are 2 and 16 colors. For an existing image, a dialog box will pop up offering different quantization methods (in the Palette section) and dithering methods (in the Reduction method section). Note that Nearest color means no dithering; Error diffusion is generally the nicest looking but slowest approach, sometimes known as Floyd-Steinberg or ``FS'' dithering in other programs. To add and view transparency, use the Colors menu again:

  1. Choose ColorsSet Palette Transparency.

  2. Choose Set the transparency value to the current background color.

  3. Choose ColorsView Palette Transparency.

To set a color other than the background color as transparent, use the eyedropper tool to pick the color and find its index. Then, in place of the second step, select Set the transparency value to palette entry and enter the index value of the color.

Paint Shop Pro currently does not support gamma correction, even though it does provide a Monitor Gamma Adjustment window (via FilePreferencesMonitor Gamma) that could in theory be used to supply the appropriate information. PSP does add a modification-time chunk, but it is incorrectly written using the local time zone of the user rather than Universal Time as required by the PNG specification.

Text annotations, including those found in other file formats, are preserved and converted as needed. In addition, the user may add text chunks with the Title, Author, Copyright, and Description keywords via ViewImage Information option. The program stores DOS-style line endings (both ``carriage return'' and ``line feed'' character codes) rather than following the PNG spec's recommendation to use Unix-style line endings (line-feed characters only).

With regard to file sizes, Paint Shop Pro always uses near-optimal compression and filtering settings on the image data. There is no option for faster compression, although PSP's own format is typically used for intermediate saves. The program's only major failing in this regard is that it always writes the maximum number of palette entries regardless of how many are used, and it doesn't reorder the palette so that the single transparent entry comes first, which would allow the remainder of the transparency chunk to be omitted. For a 50-color web icon with no transparency, this means the file will be 618 bytes larger than it should be, solely due to the overhead required to store a full 256 palette entries. With transparency, an average of 25 additional bytes would be wasted for this example, but the cost for true 256-color images may be as much as 255 bytes. As I've noted elsewhere, that can be a serious penalty for small images. In addition, PSP doesn't support writing three- or four-color images with 2 bits per pixel but instead will use 4 bits. Compression almost never makes up the difference; the output file will be roughly twice as large as it should be.

More information about Paint Shop Pro is available at Jasc's web site, http://www.jasc.com/psp.html.




Last Update: 2010-Nov-26