Thursday, December 02, 2004

Here is another command line tool. Strangely, a couple of quick web searches could not come up with a command line tool for resizing images – so I wrote my own. If you have photographs from a digital camera that you want to mail out and the images are too large for email then most of the time it involves taking each image to some sort of image editing software and resizing them and such.

 

Image Manipulation Utility v0.1

(c) Roshan James, Dec 1 2004

 Img v0.1 is built on the .Net 2.0 GDI+ API and supports only creation

 of JPG image files. Exif/Iptc metadata are lost during convertions.

 

Syntax:

     imgmanip [/S] < filepattern> [additional patterns] < image size>

         /S               - recurse subdirs

         < filepattern>    - any wildcard combination

         < image size>     - format < Width>x< Height>, Ex: 800x600

 

(Don’t tell me it looks cheesy – I know it does – but it solves the problem)

A part of this source I found on the web, so appropriate mention is given to the original article.

 

Here are a few usage examples

 

> img *.jpg 800x600

File1.800x600.jpg

File2.800x600.jpg

This basically converts all jpf files to images of 800 * 600 resolution.

 

To recursively change

> img /S *.jpg 800x600

File1.800x600.jpg

File2.800x600.jpg

Simple?

 

If the original images have any metadata information then they are not retained in the new ones. What is this? Well most cameras insert information about the camera into the image file. You can also add your custom information like a title or description or comments to the image. To see this information (on a WinXP) simple right click the image file and take a look at the properties -> summary tab. Also if you tinker around with the column settings of explorer in detail view you can display some of this info directly in explorer.

 

I can think of a bunch of simple useful things to add – format conversions, cropping, borders, grayscale etc. Lets see…

 

The code is simple usage of .Net GDI+ API. The download exe is compiled to .Net 2.0 – but you can recompile from source to the version you want. For compilation run the following from a .Net SDK 2.0 command line –

>csc img.cs

 

Download

 

Speaking of image metadata, if you are a Ruby programmer, take a look at the exif library available. EXIF is a metadata tagging standard for image files.

http://raa.ruby-lang.org/list.rhtml?name=rexif

Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview