Книга: Fedora™ Unleashed, 2008 edition

Working with Graphics Formats

Working with Graphics Formats

Image file formats are developed to serve a specific technical purpose (lossless compression, for example, where the file size is reduced without sacrificing image quality) or to meet a need for a proprietary format for competitive reasons. Many file formats are covered by one or more patents. For example, the GIF format had fallen into disfavor with the open-source crowd because the patent holder waited a while before deciding to enforce his patent rights.

If you want to view or manipulate an image, you need to identify the file format to choose the proper tool for working with the image. The file's extension is your first indicator of the file's format. The graphics image formats supported by the applications included with Fedora include the following:

.bmp — Bitmapped graphics, commonly used in Microsoft Windows

.gif — CompuServe Graphics Interchange Format

.jpg — Joint Photographic Experts Group

.pcx — IBM Paintbrush

.png — Portable Network Graphics

.svg — Scalable Vector Graphics

.tif — Tagged Image File format

An extensive list of image file extensions can be found in the man page for ImageMagick, an excellent application included with Fedora, which you learn more about in upcoming sections of this chapter.

TIP

Fedora includes dozens of graphics conversion programs that are accessible through the command line, and there are few, if any, graphics file formats that cannot be manipulated when using Linux. These programs can be called in Perl scripts, shell scripts, or command-line pipes to support many types of complex format conversion and image manipulation tasks. See the man pages for the ppm, pbm, pnm, and pgm families of commands. Also see the man page for the convert command, which is part of a suite of extremely capable programs included with the ImageMagick suite.

Often, a file you want to manipulate in some way is in a format that cannot be used by either your graphics application or the final application. The solution is to convert the image file — sometimes through several formats. The convert utility from ImageMagick is useful, as is the netpbm family of utilities. If it is not already installed, ImageMagick can be installed with the Add Remove Software GUI found in the System Settings menu; the netpbm tools are always installed by default.

The convert utility converts between image formats recognized by ImageMagick. Color depth and size also can be manipulated during the conversion process. You can use ImageMagick to append images, surround them with borders, add labels, rotate and shade them, and perform other manipulations well suited to scripting. Commands associated with ImageMagick include display, animate, identify, and import. The application supports more than 130 different image formats (all listed in the man page for ImageMagick).

Fun with ImageMagick's identify

You can use ImageMagick's identify command to identify details about image files. The welcoming splash image used for the GRUB bootloader is located in /boot/grub and is a gzipped .xpm image. If you run identify on the image, you'll discover that it's a 640?480 xpm image with 16-bit color depth. That's all you need to know to construct a replacement image of your own. Using The GIMP or another graphics tool, crop or resize your chosen image to 640?480 and change the color depth to 16 bits. Save the image as splash.xpm and then gzip the resulting file. Replace the original Fedora file, and you now have a custom boot image. The use of identify helped you duplicate the parameters of the original image to comply with the requirements of GRUB. The identify command is also useful to identify unknown image files and to determine whether they're corrupt.

The netpbm tools are installed by default because they compose the underpinnings of graphics format manipulation. The man page for each image format lists related conversion utilities; the number of those utilities gives you some indication of the way that format is used and shows how one is built on another:

? The man page for ppm, the portable pixmap file format, lists 47 conversion utilities related to ppm. This makes sense because ppm, or portable pixmap, is considered the lowest common denominator for color image files. It is therefore often used as an intermediate format.

? The man page for pgm, the portable graymap file format, lists 22 conversion utilities. This makes sense because pgm is the lowest common denominator for grayscale image files.

? The man page for pnm, the portable anymap file format, lists 31 conversion utilities related to it. However, there is no format associated with PNM because it operates in concert with ppm, pgm, and pbm.

? An examination of the man page for pbm, the portable bitmap file format, reveals no conversion utilities. It's a monochrome format and serves as the foundation of the other related formats.

Оглавление книги


Генерация: 0.051. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз