Silent Archimedes

DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu

Posted by silentarchimedes on March 11, 2009

DBP – David’s Batch Processor for GIMP

If you want to do this in the context of GIMP, download and install DBP (David’s Batch Processor). It will show up as an option under the Filters menu list. Just click ‘Batch Process’ and a GUI will pop up. You simple add files to the input list and you can do various basic image processing operations on it. They include any combinations of rotate, blur, colorize, resize, crop, sharpen, rename and image format conversion.

One drawback to DBP is that it does not allow you to add a directory or directories instead of a list of individual images. For some people that need to batch process directories of images, you will have to either manually do a directory one at a time or temporarily put all your images into one directory. This is a bit of a pain.

mogrify or convert – ImageMagick tools for Linux

If you are more of a command line guy or if you do need to batch process directories of images, mogrify or convert is the way to go. The man page of mogrify states, ‘mogrify – resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert(1) writes to  a  different image file.’

You can simply put a bunch of mogrify commands into a script file and let it run in the background. An example mogrify command to resize all your jpegs to 256×256 looks like:

  mogrify -resize 256x256 *.jpg

An example convert command to resize all your jpegs to 256x256 gifs with a prefix of images looks like:

  convert -size 256x256 *.jpg images%0d.gif

Look  at the ImageMagick’s mogrify page or convert page for more info. Speaking of, if you don’t have ImageMagick installed on your Ubuntu system, you should. 🙂

What if you want to command line convert images and put them in another directory, but keep the same names as the original images?

So at first it seemed like convert was the way to go since mogrify is supposedly only for modifying the original images in place. However, convert‘s way of doing it requires a bit of linux scripting. There is a easier in mogrify. It  has an option -path that allows you to specify an output image path.

In the following command, I want to crop out a 320×480 subimage beginning at location (160,0) in all the ppms in the tempim directory. I want the processed images to have the same names as the originals but to put them in the tempim2 directory:

mogrify -path tempim2 -format png -size 640×480 -extract 320×480+160+0 tempim/*.ppm

Advertisements

8 Responses to “DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu”

  1. lx45803 said

    “An example convert command to resize all your jpegs to 256×256 gifs with a prefix of images looks like:
    convert -size 256×256 *.jpg images.gif”

    Uh, no. That makes an animated.gif of every image that matches *.jpg.

  2. silentarchimedes said

    Lx45803, thanks for pointing that out. It has been fixed above to:

    convert -size 256×256 *.jpg images%0d.gif

    Note the added %0d to signify a naming scheme for the gif outputs.

  3. Website said

    Website…

    DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu « Silent Archimedes…

  4. New Leaf is made up a team of professionals with over decades of collective experience in assisting individuals to get the money they need today for their structured settlements payments…

    […]DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu « Silent Archimedes[…]…

  5. asp.net, c#,javascript…

    […]DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu « Silent Archimedes[…]…

  6. Sports Lines…

    […]DBP, mogrify, convert – How to batch crop, resize, rename, format convert images in Ubuntu « Silent Archimedes[…]…

  7. Baseball said

    Hi too every one, it’s inn fact a nice for me to go to see this web page, it consists of valuable Information.

  8. Timothybat said

    buying microsoft office for macbook military discount microsoft office 2013 for mac Adobe Photoshop Elements 12 windows 7 professional 64 bit full version store autodesk co jp

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: