ECN No Name Newsletter: May, 1995

The ECN No Name Newsletter is no longer being published. This is an archived issue.

[previous article] [next article]

ImageMagick-The New Graphic Manipulation Program

NO NAME NEWSLETTER - May 1995

Suzy Pelouch


Wish you could use pictures in your hypertext files? Or print out amazing pictures you've seen on the Web? Or simply display your favorite image in the background of your screen? Using ImageMagick, all of this and much more is possible.

ImageMagick is an interactive image display used in X Windows. Using ImageMagick, you can not only copy the image you want, but you can also personalize it by altering the colors, orientation, or size to your liking.

STARTING
The suite of programs that make up ImageMagick have been installed at usr/local/bin/magick. The display program is the replacement for the program XV.

/usr/local/bin/magick/display\ yourfilename

is what you type to load display. If you do not specify a file to display, ImageMagick will automatically load an image and a menu for you to scroll and select the file you want to view. Instructions for adding this program to your path is presented later.

LOADING AN IMAGE
Once you have loaded ImageMagick, you will want to choose a file to view. Initially, ImageMagick will present you with a scrollable menu listing the files in your directory. Select the one you want to display and click on the load button at the bottom.

To load a second file, select the file option from the main menu. Scroll down the menu to the load option. This will bring up the same directory menu you see when you chose your first image. Select the file, and click on load.

PLAYING WITH YOUR IMAGE
ImageMagick allows for a wide range of image personalization. I'll try to outline some of the more useful of these in the following list.

Cropping
To crop an image, select Pixel Transform from the main menu. Select crop from the scrollable menu. Move to the image that you want to crop and place the pointer where you want the corner of your cropping rectangle to be. Click and drag with the left mouse button to the opposite corner. When you release the button, you should hear a beep. ImageMagick will then reconfigure the image and display the cropped picture for you. If you wish to undo the cropping, select edit from the main menu, and choose undo from the scrollable menu. This will reverse only the last action.

Cutting
ImageMagick allows you to cut a section out of the middle of an image. To do this, select edit from the main menu. Choose cut from the sub-menu. Proceed as if you were doing a typical cropping of the whole image. Just remember that you are selecting what gets cut out, not what stays in!

Sizing
The sizing options for ImageMagick are all found on the size menu. These are completely self-explanatory.

Flipping, Flopping, Rotating and Shearing
All of these options are located under the Pixel Transform menu. To flip (turn it upside down) or flop an image (make a mirror image), select flip or flop. To return it to normal, simply repeat the command.

To rotate the image by 90 degree increments, choose rotate right or rotate left depending on which way you want to turn it. ImageMagick has the added feature of being able to rotate an image to an arbitrary angle. To try this select rotate. When you move the cursor to the image window, you will see a short horizontal line after your pointer. Click and drag with the left mouse button to adjust this line. Whatever angle you choose with this line will become the new horizontal when the image is reconfigured. When the image is rotated it is placed in a larger window. The corners that the image does not fill will be colored black by default.

Shearing the image will change it from a rectangle to a parallelogram by adjusting it one way on the X or Y axis.

[IMAGE}

Changing Colors
ImageMagick gives you many new options when it comes to color. You can change the colors in an image pixel by pixel. You can "flood" an area with color and change it all at once or you can change all areas of "color A" to "color B." To access these options choose a color from the pixel color sub-menu of the image edit menu. After you have chosen the color, choose the method by which you wish to apply the color. Point changes colors pixel by pixel, replace swaps "color A" with "color B," and floodfill floods the area with the new color. The way to map a color picture to grayscale is found under color transform. Choose grayscale.

Other Effects
On the effects menu, the options are straight forward. Sharpen sharpens the image. Blur does the opposite of sharpen. Edge detect looks for solid edges that need to be cropped. Oil painting simulates an oil painting finish for your image.

Writing on your Image (The Image Edit Menu)
ImageMagick allows you to write directly on your graphic. To do this, choose annotate from the image edit menu. Choose your font name and color, and then type your message in the graphic window. Using ImageMagick you can also add a comment to the basic information about this image. Choose comment under image edit to do this. From this menu you can also add a border to the graphic (choose add border, or select a region of interest to which you can selectively apply ANY or ALL of the ImageMagick options.

Et cetera, et cetera, et cetera
Under the miscellany menu you can find information on the image current being displayed or the version of ImageMagick that has allowed you to do all these things.

SAVING
Now that your graphic is exactly how you want it, go to the file menu and choose write. Type the file name into the provided box. To choose what format the image is to be saved as, click on the format button and scroll down the menu for your selection. When you have chosen a format and are ready to save, click on the write button.

To save an image in a different format, specify the file name suffixes in the format listing on the next page. For example, if you have a GIF file and want to save it as a JPEG file, save it as file.jpeg or file.jpg. Begin by using the File menu to select Write. Then you can choose your directory and file name. You can specify the format with a suffix on the file name, or by using the Format button.

PRINTING
To print, choose print from the file menu. Choose the page geometry that you want, and in the next window, click on print.

In this article I concentrated on only one of the programs included in the ImageMagick package, namely the display program. Also included are:

animate
displays a series of images on any workstation running an X server
combine
combines images to create new images
convert
converts input files from one image format to an output file with a differing image format
identify
describes format and characteristics of an image file; reports incomplete or corrupt files
import
reads image from any visible window on an X server and turns it into an image file; can handle a single window, the entire screen, or any rectangular portion of the screen)
mogrify
transforms image or series of images (image scaling, rotation, color reduction, etc.)
montage
composite of images to create new image

IMAGE FORMATS
ImageMagick can read and write the following formats. Note especially the support for the IBM-PC PCX and Macintosh PICT formats. Also note that ImageMagick can *read* PostScript and Encapsulated PostScript images.

AVS
AVS X image file
BMP
Microsoft Windows bitmap image file
CMYK
Raw cyan, magenta, yellow, and black bytes
EPS
Adobe Encapsulated Postscript
EPSF
Adobe Encapsulated Postscript
EPSI
Adobe Encapsulated Postscript Interchange format
FAX
Group 3
FITS
Flexible Image Transport System
GIF
Compuserve Graphics image file
GIF87
Compuserve Graphics image file (version 87a)
GRAY
Raw gray bytes
HDF
NCSA HDF
IRIS
Silicon Graphics RGB file
JPEG
Joint Photographic Experts Group file interchange format
MAP
colormap intensities and indices
MATTE
Raw matte bytes
MIFF
Magick image file format
MPEG
Motion Picture Experts Group digital video
MTV
MTV ray tracer image format
PCD
Photo CD
PCX
ZSoft IBM PC Paintbrush file
PICT
Apple Macintosh QuickDraw/PICT file
PNM
Portable bitmap
PS
Adobe PostScript file
PS2
Adobe PostScript Level II file
RAD
Radiance image file
RGB
Raw red, green, and blue bytes
RLE
Utah Raster Toolkit
SUN
SUN Raster image file format
TGA
Truevision Targa image file
TEXT
raw text file; read only
TIFF
Tagged Image File Format
VICAR
Planetary File Format
VID
Visual Image Directory
VIFF
Khoros Visualization image file
X
select image from X server screen
XC
constant image of X server background color
XBM
X11 bitmap
XPM
X11 pixmap
XWD
X11 window dump
YUV
CCIR 601 4:1:1 file.
YUV3
CCIR 601 4:1:1 files.

ADDING IMAGEMAGICK TO YOUR PATH
The ImageMagick suite of programs are installed in the /usr/local/bin/magick directory. This directory is not in the standard search path. If you are going to be a frequent user of ImageMagick you may want to add it to your search path, or create aliases for the programs you plan to use. To add the directory to your search path, the following syntax is recommended:

Bourne/Korn shell (.profile):
    PATH=$PATH:/usr/local/bin/magick
    export PATH

C shell (.cshrc/.login): set path = ( $path /usr/local/bin/magick )

If you only plan to use one or two of the ImageMagick programs (the display and convert programs are the two most generally useful), you might wish to simply make aliases for these programs instead of adding the ImageMagick directory to your search path. To do this, the following syntax is recommended:

Korn shell (.profile):
    alias display=/usr/local/bin/magick/display
    alias convert=/usr/local/bin/magick/convert

C shell (.cshrc): alias display /usr/local/bin/magick/display alias convert /usr/local/bin/magick/convert

The Bourne shell does not support aliases; if you are using the Bourne shell (you probably aren't), you will have to add the ImageMagick directory to your path.

For more information on these programs, consult the manual pages. The overview page can be viewed by typing man ImageMagick .


webmaster@ecn.purdue.edu
Last modified: Friday, 12-Sep-97 18:32:33 EST

[HTML Check] HTML