March 20, 2019

Building Attractive Web Photo Galleries - page 2

Good News and Bad News

  • December 20, 2004
  • By Carla Schroder
Most digital cameras give you a choice of several options for file format, most commonly JPEG or EXIF (Exchangeable Image File Format), TIFF (Tagged Image File format), and RAW. There are also various proprietary file formats that some of the different manufacturers use, such as PCD, or Photo CD. EXIF/JPEG and TIFF are universal formats, so stick with those. For most folks, EXIF/JPEG is just the ticket. It's compact, so you can store more pictures in your camera memory, yet it produces images of good quality. To learn more about these, see Akkana Peck's excellent Image Formats for the Web and Elsewhere.

Some of us stubborn oldtimers still prefer film cameras. We like being able to look at our photos without needing a computer, and we like the quality of photographic prints. And the longevity of digital storage is still quite doubtful, as is the quality of computer-generated hard copies. So we prefer to scan prints for posting on Web pages. The best file formats for scanned photos are either TIFF or JPEG, depending on how fussy you are about image quality. JPEG is faster, because you need JPEG format for your Web pages anyway, and it usually looks fine.

Suppose you have a TIFF file to convert to JPEG. First make a backup copy of the file, then use the mogrify command:

$ cp image1.tif image1.tif-bak
$ mogrify -format jpg image1.tif

mogrify will not overwrite the original file when you convert it to a new file format. However, there are many operations where it will overwrite the original. In any case it's always safer to work from a copy.

Since you're creating a Web photo album, you doubtless have a whole batch of pictures to convert. Put them all in a single directory, make backup copies, and with one command convert the file format and resize them:

$ cp -r /images /images-bak
$ mogrify -resize 640x480 -format jpg images/*.tif

This does not make all the pictures exactly 640x480; this sets the largest dimensions, and the images are resized proportionately. For example, if the original image is 800x1100, it will be resized proportionately to 349x480. If it starts out at 1100x800, the resized image will be 640x465. So this is perfect for resizing a directory full of pictures of different sizes and orientations. If you want an exact size, add an exclamation point:

$ mogrify -resize 640x480! -format jpg *.tif

Then create your album. The dot means you are in the directory that contains the images:

$ album .

And you're done. Really. Look for the index.html page and open it in a Web browser. You'll see something like this example.

Most Popular LinuxPlanet Stories