ImageManip

2004-01-17 : A chance to work on a bit of a project, finally!

OK, so my photo album has been hanging over my head for years. I have all these ideas, but I never get around to writing anything. One of the things that I've been sorely lacking is an automated way to create thumbnail images. Now, I created a teeny app back in 2002 called imagesize that could report the size of an image file, using GDI+ as the graphics library. I decided it would be a perfect base to expand on to create a resizer.

Interesting Aspects

I pulled in some old (1999) C++ helper files, so the style is a little mixed (old and new). But I created a new experiment for error handling: a struct called ErrorCode that keeps both the code and the type. That way I can have HRESULTs, Win32 error codes, and Gdiplus::Statuss all mixed together and handle things uniformly. This project is too small to be more than a proof of concept - it would be insteresting to see if this idea holds up to a larger project.

I got badly burned in 2002 by another app I had that was supposed to resize images. I hit a bug and it corrupted all the images I was trying to generate thumbnails for. I wrote this one such that it is very diffucult to accidently overwrite the originals.

I'm starting to get the hang of Visual Studio 7. :)

The Program

Usage:

imagemanip /?
           /size:<filename>
           /resize /in:<filename> /out:<filename> /width:<size>
               /height:<size> [/quality:<num>] [/overwrite]
               [/overwriteSource]
  ? - this help screen.
  size - print out the dimensions of the specified image in
    "<width> <height>" format.
  resize - resize the specified image.
    in - (required) input filename.
    out - (required) output filename.
    width - (required) width of output file, between 1
      and 5000.
    height - (required) height of output file, between 1
      and 5000.
    quality - (optional) quality of compressed image, between
      0 (worst, most compressed) and 100 (best, least compressed),
      defaults to 85.
    overwrite - (optional) allows the target file to be overwritten
      if it already exists. Not allowed by default.
    overwriteSource - (optional) allows the source file to be
      overwritten as the target. Not allowed by default.

You can get the source via anonymous CVS at

  • cvs -d :pserver:anon@www.latenighthacking.com:/code-cvsroot co 2004/imagemanip
    C o m m e n t s :    
    (nothing yet)
    Edit