Unitar!

Site admins each have their own goofy requirements for avatar image dimensions, formats and filesizes. Currently, I have no less than 8 copies of the same avatar, in different scales and file formats, and I suspect it’s only a matter of time before I need more.

Rather than continue to open up my huge layered XCF file in The GIMP and do a Cubic Scale and Save As and then SCP it to my web server every time, I’ve decided to write a Perl script to do it all for me using ImageMagick. It’ll be a CGI script that can be queried with a GET request with 4 parameters: image ID (for different avatars), width, height, and format. At least that would be the first try. There are 2 possible problems: one, I’m assuming the web scripts that take these image URLs either don’t need to know the format or get it from the file header or HTTP response header rather than the file extension, and two, I’ve so far ignored the filesize requirement. If the first problem pops up, I’ll have to figure out some way for my web server to parse a requested URL string with the proper extension and return the appropriate file (and currently, the only way I can think to do that is to write a web server). If I run into the second, I’ll have to add a parameter for maximum filesize, then have the script check the size and maybe increase the compression ratio if it’s too big.

Apr 9th, 2007
Tags:
  1. Apr 9th, 2007 at 22:13 | #1

    I used the GD library when I wrote my image gallery… To resize jpg’s to thumbnails and display size, etc. There are functions in that to tell you what type of file you are dealing with, and what type to save it as. http://ca.php.net/gd not sure if that helps your particular case.. but it worked great for my application.

  2. Apr 10th, 2007 at 14:15 | #2

    Excellent, I don’t really know PHP, but it sounds like it would be a bit more efficient than using ImageMagick on the command line, so I guess I’ll learn.

Comments are closed.