Linux Today: Linux News On Internet Time.

More on LinuxToday

Linux tip: Creating a pixel ruler from the command line

Jul 24, 2009, 19:03 (0 Talkback[s])


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

"Sometimes I need to draw a few lines or some text on an image or a blank canvas. Just recently I needed to include a simple image of a pixel ruler in a developerWorks article. I wanted the image to be 572 pixels wide, to match the current recommended maximum for developerWorks article images as described in "Illustrating your article or tutorial for developerWorks." Lots of on-screen pixel rulers are available for Linux and for Windows (see Resources), but I just wanted a simple GIF, JPEG or PNG image. This tip shows you how to use Bash scripting, shell arithmetic, and ImageMagick to create a pixel ruler. Make a canvas

"The first thing any artist needs is a canvas, so let's create one using the XC pseudo image type in ImageMagick. We also need a color, either one of the many named colors in ImageMagick, or a custom color. (See Resources for a link to the ImageMagick documentation, where you can find a full list of pseudo image types as well as color names.) Listing 1 shows how to make a light blue 572x100 canvas using the convert command. (The convert command is customarily used to convert to a different image format or otherwise alter an image.)

"Listing 1. Creating a canvas

convert -size 572x100 xc:lightblue ruler1.gif

"Figure 1 shows our new canvas."

Complete Story

Related Stories: