SHARE
Facebook X Pinterest WhatsApp

Linux tip: Creating a pixel ruler from the command line

Written By
thumbnail
Web Webster
Web Webster
Jul 24, 2009

“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
572×100 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 572×100 xc:lightblue ruler1.gif

“Figure 1 shows our new canvas.”


Complete Story

thumbnail
Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Recommended for you...

5 Best Free and Open Source Text Expander Tools
webmaster
Jun 13, 2025
Grafito: Systemd Journal Log Viewer with a Beautiful Web UI
Bobby Borisov
Jun 12, 2025
FreeBSD Wants to Know a Few Things
brideoflinux
May 11, 2025
NVK enabled for Maxwell, Pascal, and Volta GPUs
Kara Bembridge
May 1, 2025
Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.