I use Vmware extensively. If your unfamiliar, Vmware makes it possible to run other operating systems within but separate from your own. In addition, Vmware allows you to take screen shots. However, those screen shots are too large for posting as they make my sidebar disappear. As such, I need to scale them down to a maximum width of 640 pixels. I used to use Photoshop to automate the resizing of these images. I do not have access to Photoshop after recently upgrading my main machine and finally dumping Windows.

I knew Gimp had scripting built-in, which I planned on using to automate the resizing of said images. Not surprisingly, trying to understand the GUI was pure hell. Luckily after 15 minutes I remembered imagemagick.

I installed imagemagick on my ubuntu machine in about 5 seconds:

noland@mojito:~/Desktop$ sudo apt-get install imagemagick
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
html2ps
The following NEW packages will be installed:
imagemagick
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/740kB of archives.
After unpacking 3232kB of additional disk space will be used.
Selecting previously deselected package imagemagick.
(Reading database ... 99849 files and directories currently installed.)
Unpacking imagemagick (from .../imagemagick_7%3a6.2.4.5.dfsg1-2ubuntu1_i386.deb) ...
Setting up imagemagick (7:6.2.4.5.dfsg1-2ubuntu1) ..
.

And then used find to resize all of them in about 10 seconds.

find . -type f -name '*.png' -exec convert -resize 640x {} {} \;

I LOVE the command line!

8 Responses to “imagemagick: command line photoshop, only so much better”

  1. nippyda Blog Archive » imagemagick: command line photoshop only so much better Says:

    […] full story here […]

  2. Horsefug.Com » imagemagick: command line photoshop only so much better Says:

    […] wrote an interesting post today on imagemagick: command line photoshop only so much betterHere’s a quick […]

  3. Fintan Says:

    Brilliant tutorial, I had wondered how people take screen shots of linux installations and it turned out use VMware.. Why didn’t think of this :-( .

    Thanks for sharing command line tip of resizing pictures.

  4. James Says:

    I also love imagemagick. Some things I’ve found useful:

    convert -geometry 640×640!

    The ‘!’ will force the exact resolution. Convert will try and keep your aspect ratio intact if you simply supplied 640×480.

    mogrify will change the image in-place.

    mogrify -resize 640x

    identify will give you useful information about the image (such as its type and resolution) right on the command line:

    $ identify t2.png
    t2.png PNG 128×128 128×128+0+0 DirectClass 16-bit 7.83984kb

  5. The Geeky Blog Updates » Blog Archive » imagemagick: command line photoshop only so much better Says:

    […] Read the rest of this great post here […]

  6. love » imagemagick: command line photoshop only so much better Says:

    […] Read the rest of this great post here […]

  7. ahmadinejad Says:

    Bash rules…. Command Line interface is greattt.. Many things could have done in seconds. Nice tips..

  8. Tmbigrigg Says:

    I want to use ImageMagick to convert a series of photos to Sepia and black and white.
    OK so I can use dcraw to convert the NEF (RAW) files to .JPG. and I can use the following command to

    convert to Sepia-Tone and black and white:
    [I]convert filename.JPG -sepia-tone 75% filename.sepia-tone.JPG[/I]
    [I]convert filename.JPG -colorspace Gray filename.bw.JPG[/I]

    How can I use these commands in a script that will act on multiple filenames within a directory and/or

    directory tree. The following is an example of the directory structure that I want to work with. I would

    also ideally like to save the Sepia and Black and White JPGs in their own folders within the parent

    directory. The final result would be something where 2008-05-07, 2008-05-09 and 2008-05-15 would end up

    with additional directories for Sepia and BW created and the sepia and BW files moved into those directories.

    [B]2008-05-07[/B]
    DSC_1000.JPG
    DSC_1001.JPG
    DSC_1002.JPG
    DSC_1003.JPG
    [B]2008-05-09[/B]
    DSC_1004.JPG
    DSC_1005.JPG
    DSC_1006.JPG
    [B]2008-05-15[/B]
    DSC_1007.JPG
    DSC_1009.JPG
    DSC_1025.JPG

Leave a Reply

If Wordpress eats your comment (shell output, loops, ex..) email the text to me.