Why would you want to do image work from the CLI? That's a good question. I've got a good answer. Speed and ease. Let's do a quick comparison. I love the GIMP, make no mistake about it. One of the things I've used it to do over the years is screen captures. The GIMP makes it pretty easy to capture a window or the full screen.
All you need to do is start the GIMP, then click on File->Acquire->ScreenShot. That brings up a dialog window where you can select full screen or specific window, whether or not you want all the window decorations, and set a delay time in seconds by pointing at the up or down arrows provided for that purpose. Then click "OK". If you've chosen to capture a specific window, your next task is to click on it. That's pretty much all there is to it. Oh, except that then you have to save the image you've just captured, but that too is only a few more clicks and the typing of the file name and extension.
To accomplish the same thing from the command line using ImageMagick's import, simply type this:
import window.png
Then click on the window you want to capture. You're done. Let's see, from the command line, that means typing nine characters, hitting enter, and then a single click with the mouse. Using the GIMP, which I truly love, by the way, I am not trying in any way to disparage it, the same task requires at least eleven clicks, plus typing the file name.
Thats one click and ten keystrokes from the CLI, and eleven clicks and nine keystrokes from the GUI. But who's counting keystrokes and clicks? Elapsed time is a better metric. About two seconds from the command line and fifteen-to-thirty in the GUI. Get the picture? In this comparison, the CLI wins in speed and ease.
More on import
Here are some examples of using import to capture screens and windows. I typed the following in the terminal window shown in that image to capture the entire screen and name the image "import-1.png":
import -window root cli-image-1.png
But since I'm only interested in one specific window and not the whole screen, this is what I typed to grab the window containing the photo of donkeys.
import cli-image-2.png
Click to see what the single window capture looks like. After looking at the image just captured, I decided that I would like to crop the image just a bit. I wanted to focus on the heads of the three donkeys and lose the window trim.
I decided to use the mouse from the CLI to accomplish this. First I displayed the capture by entering:
display cli-image-2.png
The I repeated the earlier import command, naming the resultant image cli-image-3.png. After entering the import command, instead of simply clicking on the window to grab it, I left-clicked and held the button down, then dragged the mouse pointer from the upper left to the lower right of the region I wanted in the image, and released the mouse button. The image below is the result of that capture.
Want to make it look like a blizzard from the 1890s? Display it using the "-monochrome" option. There are dozens of other tweaks that you can do with import and display, but that's enough for them here. Let's move on to mogrify.
What is mogrify?
Mogrify allows you to transform digital images in a number of ways, including (this from the man page) "image scaling, image rotation, color reduction, and others." Please note that mogrify can work on a single image or on a sequence of images.
For example, if you want to transform all the .tiff images in a directory to .jpg, you can do it with a single command:
mogrify -format jpeg *.tiff
That will convert all the TIFF images in the directory to JPEG, whether it's a single image or hundreds of them. Feel the power?
Need to make thumbnails? Easy as pie, but be careful with this one. The thumbnails are written over the original file names so always work from backups when making thumbnails. Enter this command in the directory containing the images you want thumbnails of:
mogrify -geometry 120x120 *.jpg
One last comment about these tools from the ImageMagick suite. I recommend going to the ImageMagick website for documentation on using them rather than relying on the man pages. The man pages don't seem to have been well maintained.
Note: Comments are owned by the poster. We are not responsible for their content.
I gotta say, I really enjoy these series of articles. They're broken down into bite-size chunks that seem just right. It's hard for me to know for sure, since I've been using unix-like shells for such a long time, but it seems that this would make for some good start-from-scratch learning material.
Writing about <tt>import</tt> and <tt>mogrify</tt> is a neat idea. I use these tools very often to modify both screenshots, and pictures from my digital camera. This is very handy. The flexibility of modern unix shells makes it even nicer (hopefully these articles will eventually get into some nice looping or conditional structures, if that's not too advanced for the target audience). It might also be a good idea to mention that ImageMagick comes with a few other useful command line tools. A list of these is available in <tt>man imagemagick</tt>. Maybe you'll write some more articles later, but I mention this for folks are seeking more information right away.
One final point I'd like to bring up -- and I hate to be a troll, as I've posted about this before -- but I find it curious that you use the word "noobies" instead of the more common "newbies". Is there any reasoning behind this word choice, or are you simply weird? (Not that being called weird should be taken as much of an insult. How weird am I for noticing and repeatedly mentioning this?)
Hmm. According to Google Groups, "newbies" is not only much more popular, it's also older. The earliest "newbies" result I got is <A HREF="http://www.google.com/groups?q=newbies&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&scoring=d&as_drrb=b&as_mind=12&as_minm=5&as_miny=1981&as_maxd=23&as_maxm=2&as_maxy=1990&selm=445%40apctrc.UUCP&rnum=43&filter=0" TITLE="google.com">from 1988</a google.com>, but the earliest "noobies" result is <A HREF="http://www.google.com/groups?q=noobies&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&as_drrb=b&as_mind=12&as_minm=5&as_miny=1981&as_maxd=23&as_maxm=2&as_maxy=1995&selm=357v93%245cd%40Starbase.NeoSoft.COM&rnum=5" TITLE="google.com">from 1994</a google.com>. I'm probably risking trollification here, but I don't follow your reasoning. I guess usenet isn't the end-all be-all indicator of word usage, but it's as good as anything I could think of. I think I'll let this subject drop now, though. I've probably annoyed enough people as it is with my off-topic blathering.
Noobies v newbies
Posted by: Joe Barr on February 24, 2004 10:30 PMThe long answer
The first article in this series was dripping with a faux "boot camp drill instructor addressing recruits" kind of attitude. You know, the whole "Whattsa matter, sweetheart, did your mommy forget to pack your favorite jammies?" thing.
For that kind of opening to work, one phrase in particular needed to have grit: nattering noobies. To my ear, the double t's in nattering called out for an alternative spelling which would echo the repetition. "Nattering newbies" just doesn't work as well for me.
The short answer
Yes, I'm weird.<nobr> <wbr></nobr>:)
#