Add text to images with Linux 'convert' command

 by rhackenb
convertintro1.jpg
This instructable will show you how to add text to an image using the convert command in Linux. One valuable use of this is the placing of a caption on an image for documentation. Another use would be the placing of a time stamp on an image that gets generated automatically by a webcam.

There are many convert options that you can make use of in placing text on the image. You can choose the starting point for the text (via a height/width coordinate), the fill color of the text, the point size of the text, and the font used. This instructable will show you how to do all this.

The major catch with this instructable is that you have to do all this in the Linux operating system. I'm not aware of a utility such as convert in Microsoft Windows but who ever does anything with a command line in Windows? This instructable is more aimed at Linux users who want to get more out of their computer. If you are a Windows user and are still tempted to read this instructable, you may be tempted to download and install Linux. I may write an instructable on how to do this at a later date but if you want to pursue this on your own, you can go to http://www.ubuntu.com/ and start the process. You can turn your computer into a dual-boot machine (I'd really recommend that you install a second hard disk in your machine -- any size will do). BTW, Linux is FREE, along with everything available to it. Also, so far, it is invulnerable to viruses.
 
Remove these adsRemove these ads by Signing Up

Step 1: The linux 'convert' utility

To perform the task of adding a label to an image, we will be working entirely within a Linux terminal window. Windows calls this a command window but it is rarely used in Windows except by oldtimers who remember it from the DOS days. Linux users make heavy use of it.

First of all, bring up a terminal window. With Ubuntu Linux, you do this by selecting Applications->Terminal. A window will open up with a command line prompt. It will put you at your home directory.

Let's assume that the image you want to play with is in an "images" subdirectory. To get to that subdirectory, type "cd images". Issue the comman "ls" to see what files are there. In my case, I want to work with a file called "sunset1.jpg".

You also want to make sure that the convert command is available on your system. One way to do this is to issue the command "which convert". If it is available, its location will be printed to the screen. In my case, it is at "/usr/bin/convert". Another way to find out if it is available, just issue the command "convert" at the command line. If it is there, a long description of the command will be printed out with all the options available. If it is not there, you will see "convert: command not found". Let's assume that it is available.

If you issue the bare command "convert" you can see that it is a very powerful tool with many capabilities. A more complete description of the convert command can be found at:
http://linux.about.com/od/commands/l/blcmdl1_convert.htm

For our purposes, we only want to use the "-draw" argument to write the caption to the photo.

11010010110 says: Feb 16, 2009. 1:07 PM
convert is part of image magick. it exists for windows too

you still are wellcome to the linux world ! though i'd suggest mandriva kde (for most users) or arch (for advanced users) over ubuntu
hintss in reply to 11010010110Dec 2, 2010. 4:56 PM
I'm thinking of switching to arch. anything I should know (yes, I know its simple, from a programmers point of view, I read the wiki some, I read the beginners guide, etc)?
xACIDITYx in reply to 11010010110Feb 27, 2009. 10:06 AM
Blegh. Ubuntu is the easiest for new users, especially with it's very extensive documentation with fixes for essentially all problems you may come by.
11010010110 in reply to xACIDITYxFeb 27, 2009. 10:57 AM
ubuntu has few times more problems than any other distro i tried ubuntu newbies come to me to ask for help with amont of problems way higher than other distros
hintss in reply to 11010010110Dec 2, 2010. 4:55 PM
my vista partition on my other machine broke
rhackenb (author) in reply to 11010010110Feb 27, 2009. 4:51 PM
I have installed Ubuntu for several of my friends. One of them, a 75 year old who was having virus troubles with Windows, brags about his installation. The only time he has contacted me about a problem was after a major automatic upgrade, he was not able to print anymore. I told him to chose his printer instead of the default PDF target that Ubuntu mysteriously choses as the default. After he simply looked at his choices, the problem was solved. Ubuntu is an excellent installation and a great replacement for Windows for people who don't really do more than browse the web and check their web-based email. They don't even notice the difference. Of course, it's good for most everything else. Ubuntu is the best distribution I every found, mainly because of it's ability to install software from many sources.
11010010110 in reply to rhackenbFeb 27, 2009. 5:08 PM
you should be lucky. enjoy ! i know ubuntu as a distro slower than windows xp (unless windows is infected or overloaded with crap) and one that creates problems every here and there and they come back after you allredy fixed them
rhackenb (author) in reply to 11010010110Mar 2, 2009. 12:24 PM
My experience is completely the opposite. I dual-boot machines and I always find Ubuntu to be faster than XP on the very same machine. I generally have no problems with ubuntu once I get stuff installed. I never see a problem get solved and then come back. The only real problem I ever have is when I don't automatically have drivers for things like Wi-Fi receivers. However, once the driver is installed, there are nor more problems with it. I installed Ubuntu on a 75 year old's machine. He is totally amazed by how fast the linux side runs compared to his XP side (I had totally wiped his XP and reinstalled it). He never calls me with problems. I've been using various distributions of Linux since the early 90's. Ubuntu is by far the best and most user-friendly. It now even performs major upgrades to the kernel without assistance from me.
11010010110 in reply to rhackenbMar 2, 2009. 12:45 PM
enjoy !
hintss says: Dec 2, 2010. 4:54 PM
*almost everything is free

anyway, you should try phatch. it batch processes photos, and it has many capabilities. and the best part: its for linux only! muahaha
Computothought says: Apr 28, 2010. 3:23 PM
Cool... New trick for the arsenal.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!