Converting images with Kim

Picture Manager

By Peter Bubenik and Marcel Hilzinger

With a Konqueror-integrated service menu called Kim, you can modify and manipulate image files through a handy context menu. <@65_VA>By Peter Bubenik and Marcel Hilzinger

Whereas Windows has let applications add functions to the Explorer file manager for some time, KDE version 3.2 was the first version of KDE to give users this ability. KDE 3.3 included a version of Konqueror with a separate context menu for image files. Thanks to this menu, users can right click to view, rotate, and scale images directly from within Konqueror.

The KDE Image Menu (Kim) by Charles Bouveyron [1] takes this feature a step farther. Kim gives you far more options than a Windows user can expect. The context menu allows users to convert, compress, rotate, crop, and mail images in various formats via Konqueror. The program can even create an MPEG clip from an image directory. Kim draws on the functionality of the ImageMagick [2] image manipulation program and Mpegtools [3]. Kim also integrates Kalbum [4], a KDE program designed for creating Web galleries and photo albums.

Box 1: Creating a PAL-formatted Movie

01 [Desktop Action WebExp75800]
02 Name=Pal-Movie: 768x576 at 75 %
03 Name[de]=Film im Pal-Format : 768x576 bei 75 %
04 Icon=tgz
05 Exec=kimgsm_webexport 768x576 %D %U && images2mpg -T /tmp -d
06 `kdialog -- inputbox "Choose duration of each image (sec):" 3`  -t
07 `kdialog -- inputbox "Choose transition speed:" 5` -o
08 `kdialog -- getsavefilename %d *.mpg` -i %U

Download and Installation

The Kim website [1] includes packages for Debian and Suse 9.1, as well as a tar archive file. For this discussion, I'll assume you're installing from the archive.

Start the installation by copying the archive file, kim_0.7.tar.gz, to any directory. Then unpack the file by typing:

tar xvfz kim_0.7.tar.gz

Change to the directory this step creates, and type su to become root (Suse Linux has the sux command for this purpose). Then launch the install script by entering ./install.sh. A Kdialog window appears, giving you the following options:

If you would like to install the plugins, you will need Mjpegtools, Digikam, and Kalbum. Digikam also requires the kipi-plugins package (Digikam 0.7.X) or digikamplugins (Digikam 0.6.X). These packages include the image2mpg script that Kim uses to convert images to an MPEG movie. Suse Linux users need to install the Mjpegtools from [5], as the original Suse package is missing a number of important programs. Users of other distributions can typically install the Mjpegtools package without any changes, but you may have some difficulty with Digikam. For example, Fedora Core 3 does not have any Digikam Version 0.7 packages at all, although the packages from [6] and [7] with Digikam 0.6.2 will run under Core 3.

The installer does not check whether the required tools actually exist on your system, and this can mean that nothing happens when you select a specific menu item. In fact, Kim will not even give you an error message if the tools are not present.

The plugins give you menu items for launching Kalbum with selected images and for blurring or normalizing images with Imagemagick. Add a couple of entries for creating a slideshow with or without sound in MPEG format. As KDE version 3.2 or later has an image manipulation drop-down menu, Kim creates a safe copy of the original menu when you install, storing the menu entries in $KDE/share/apps/konqueror/servicemenues/ before finally deleting the original entries.

On our two lab systems with Suse Linux 9.1 and Fedora Core 3, the Kim installer printed several error messages before saying Good bye, which is Kim's way of saying that the install completed successfully. Deinstalling Kim was just as easy, and there were no major issues using the program.

Main Functions

Kim's main menu (see Figure ) has four items. Compress and Resize allows users to compress and resize multiple images at the same time. Besides common formats, Kim also gives users the option of individually specifying the compression factor or size. The bottom three menu entries are for Web export, which is useful for readers who maintain homepages. For example, a single mouse click will compress TIF-formatted images from your 5 Megapixel camera to a handy 600 x 800 homepage-compliant format with a compression rate of 75 percent.

Box 2: Creating MPEG Videos

Let's assume you have a directory with 100 JPEG-formatted images at a resolution of, say, 2048 by 1536 pixels (about 3 Megapixels). You would like to create an MPEG video from your favorite 25 and burn the results onto a video CD.

Under ideal circumstances, all 25 images would be in landscape format; but portrait format will work too. Select the images you need for the video (press down the [Ctrl] key in Konqueror to do so). Right click on one of the selected images and select Actions | Kim - Convert and Rotate | Convert to PNG. This option tells Kim to create copies of the JPG files in PNG format. We now want Kim to create a movie from these copies. Now select the 25 new PNGs, instead of the original JPGs, and select Actions | Kim - Compress and Resize | Resize (640x480 pixels) from the context menu. Right click one of the selected files and select Actions | Kim - Plugins <$>| Make an Mpeg movie.

Kim pops up three dialogs to prompt you for the display and cross-fading intervals for the individual images, and then asks you to enter a name for the movie file. The images2mpg script then generates a video within a few minutes depending on your CPU performance. The program does not give you a progress indicator, but the fact that the CPU load goes up to 100 percent means that Kim is obviously working hard. You can delete the PNG-format source files when you are satisfied with the movie.

Note that many manipulation steps occur without a prompt or an undo feature. For example, if you convert all the images in a folder from 2032 x 1536 (3 Megapixels) to 640 x 480, you irrevocably lose the original images. It makes sense to create a safe copy of the files first before going on to manipulate them.

The best way to create a safe copy is to select Convert to TIF from the Convert and Rotate menu. TIF is a useful format for a safe copy because it supports loss-free manipulation. In contrast, the quality of JPEG images is affected with each change you make. Besides conversion and rotation options, the menu also has an entry for mirroring (flipping) images.

The Plugins menu gives you entries for creating an MPEG movie (see Box 2) or a Web gallery with Kalbum. The menu also has an entry for softening images (Gaussian Blur) and for normalizing the colors (Normalize Image).

Finally, the Publication and treatment menu has entries that allow users to mail images, convert images to black and white, or add a frame.

Figure 1: The Kim main menu appears when you right click an image file.

Extensibility

The menu entries are simple shell functions, so you can easily modify menu entries or add new entries. For example, if you often need to convert files to 350 x 500 format, you can add an entry for this task to your kimgsm_compressandresize.desktop file. There is no need to modify the script file (bin/kimgsm_webexport).

If you regularly create videos from images for viewing on your TV set, readers in Europe might also like to convert the images to the PAL format (768x576 pixels). Again, you can add an entry to the Compress and Resize menu to do this and link it with the entry for creating a movie. Box 1 gives you an example. Kim does not give you a progress indicator for complex tasks, but the top command will allow you to see which program is performing which steps. A Centrino processor system running at 1.4GHz took about quarter of an hour to create a slideshow with 30 images.

INFO

[1] Kim: http://bouveyron.free.fr/kim/

[2] ImageMagick: http://www.imagemagick.org/

[3] Mpegtools: http://www.metzlerbros.org/dvb/

[4] Kalbum: http://www.paldandy.com/kalbum/

[5] Mjpegtools for Suse: http://packman.links2linux.org/

[6] Digikam for Fedora: http://manta.univ.gda.pl/~mgarski/RPMS/digikam/

[7] Digikamplugins for Fedora: ftp://ftp.icm.edu.pl/vol/rzm8/linux-kde-redhat/kde-redhat/fedora/1/RPMS.stable/digikamplugins-0.6.2-0.fdr.0.1.i386.rpm