Friday, May 25, 2007

convert: linux command line image conversion and processing utility

I needed a quick and dirty command line tool to convert a jpg to a png. Lo and behold, I found the image conversion utility called "convert" on my Fedora Core 6 system from the ImageMagick open source tools, http://www.imagemagick.org/. ImageMagick is now part of the graphics programs packaged with the Core 6 distribution.

Anytime I have a simple task that I can automate or just speedily get done, it usually involves a command line tool. I love command line tools for this reason. I won't belabor describing the software because Linux Journal has already done it for me here:
http://www.linux-mag.com/id/2561/

You can do basic things like resize, crop and convert to different formats. Your command can be as simple as this:
convert [sourceImage] [destinationImage]

example:
convert image.jpg image.png

It is that easy. No opening GIMP just to convert. The program can also do sophisticated image processing using effects. Typing "convert" with no arguments after the command name will give you a full list of the capabilities of the software.

To scale an image, try this command:
convert [sourceImage] -scale [WidthxHeight] [destinationImage]

example:
convert image.jpg -scale 1024x768 newimage.jpg

This is a great utility folks.

Good man page here:
http://linux.about.com/od/commands/l/blcmdl1_convert.htm

Enjoy!

3 comments:

Mark M. Bravura said...

Thanks, Mule - extremely handy post!

Best regards,

Mark

Cacasodo said...

no prob, glad u liked!

Mark M. Bravura said...

Hello again, Mule,

I was hoping you might be able to point me in the right direction toward a viable solution.

After spending several hours brooding over the ImageMagick documentation, I found nothing similar to the following scenario:

I have several 480x640 JPGs, and my goal is to center each one onto a 600x800 transparent background and export them as PNGs with transparency.

Any guidance you could give on this would be deeply appreciated.

Best regards,

Mark