Crop images using the shell?
May 23, 2006 10:58 PM   Subscribe

Is there a console app for *nix that I can use to crop images?

The images are 640x480. I want to cut them in half horizontally, and then cut each half into four separate images vertically. I know I can do this in gimp, but I'd rather do it quickly using the shell. I'm flexible when it comes to file formats (they're PNGs, but it wouldn't be a problem to mass-convert them all to JPEGs). Bonus points for an app that has Debian or Ubuntu binaries available. Thanks!
posted by ori to Computers & Internet (8 answers total)
 
ImageMagick or NetPBM should be able to do that.
posted by tumble at 11:01 PM on May 23, 2006


and I almost forgot Gimp Script-Fu
posted by tumble at 11:05 PM on May 23, 2006


ImageMagick is very easy to use, imo. It is also incorporated into scripts easily. I can't offer any support for NetPBM or Gimp Script-Fu as I have never tried them, ImageMagick has always been more than adequate for my modest needs.
posted by Loto at 11:50 PM on May 23, 2006


Read the man page for 'convert'.
posted by salmacis at 2:16 AM on May 24, 2006


It seems like
convert -crop 640x240 untitled.jpg output.jpg
will do your first part.

Turn on -verbose and you see that it's creating output-0.jpg, output-1.jpg and so on. The original "filename,jpg" chopped into four.

So then I guess you just need to do
convert -crop 160x240  output0.jpg tophalfoutput.jpg
and
convert -crop 160x240  output1.jpg bottomhalfoutput.jpg
that is, if I understood what you meant.

This is the convert command of ImageMagick of course.
posted by AmbroseChapel at 3:20 AM on May 24, 2006


Oops.

The original "filename,jpg" chopped into four.


Was meant to be "The original "untitled.jpg" chopped into two"
posted by AmbroseChapel at 3:22 AM on May 24, 2006


Seconding ImageMagick in general and convert in particular.
posted by primer_dimer at 5:48 AM on May 24, 2006


The python imaging library would also work well, and if you know python, you'll likely find it easier to pick up than imagemagick.
posted by gsteff at 9:59 AM on May 24, 2006


« Older box of grey   |   How young is too young Newer »
This thread is closed to new comments.