Silent Archimedes

Posts Tagged ‘David’s Batch Processor’

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

Posted in Computers, Linux, Technology | Tagged: , , , , , , , , , , , , , , , | 7 Comments »