Fully functional replacement for taimg, using the ImageMagick module for PERL.
#!/usr/bin/env perl # taimagick 1.2.1 # Image::Magick based image indexing and conversion program for obscura 2 # # Copyright (C) 2005, Steve Block # # Portions based on taimg 2.0, Copyright (C) 2003-2004 C. Alexander Leigh # For more information see http://www.ashpool.com/obscura/ # # Released under the GNU GPL # Strict syntax # Load ImageMagick use strict; use Image::Magick; # Create index.cat file in the current directory # The format of this file is as follows: # imagename (without extension)|Title|Camera|Copyright|Location|Date sub makeIndex { # Open currently directory and prepare to write index.cat file # Quit with an error if unsuccessful opendir(DIR,".") or die("Cannot read directory.\n"); open(FH,">index.cat") or die("Cannot open index file for writing.\n"); my($fn); # Default camera and copyright values. Change these to fit your # equipment and desired copyright string my $defaultTechnical = "Canon T70"; my $defaultCopyright = "Copyright © 2005, Steve Block"; # Read filenames in the current directory. If the file name ends in .jpg # (case sensitive) then add it's name and information to the index.cat # file. while($fn = readdir(DIR)) { if($fn =~ /^.*\.jpg/) { $fn =~ /^(.*)\.jpg/; print FH "$1|$ARGV[1]|$defaultTechnical|$defaultCopyright|$ARGV[2]|$ARGV[3]\n"; } } close(FH); } # Create 400 pixel wide image for the front page of steveblock.com # The argument is the name of an image. Creates smaller image as # $imagename-400.jpg in the scale directory sub makeFP { my($file) = @_; my($fpfile) = $file; # Generate filename $fpfile =~ /^(.*)\.jpg/; $fpfile = "scale/$1-400.jpg"; # Only bother if the file isn't there. if(!-e $fpfile) { # Create ImageMagick object my $image = Image::Magick->new; # Read original image into the object, echo errors my $rc = $image->Read($file); warn "$rc" if "$rc"; # Create the 400 pixel image $image->Set(quality=>'85'); $image->Set(density=>'72x72'); $image->Set(interlace=>'Line'); $image->Resize(geometry=>'400x400'); $image->UnsharpMask(radius=>1.3, sigma=>1.1, amount=>40, threshold=>0.05); $image->Write($fpfile); undef $image; } return 0; } # Create small square thumbnail sub makeSq { my($file,$sqfile) = @_; # Create ImageMagick object my $image = Image::Magick->new; # Read the image into the object, print any errors that occur my $rc = $image->Read("$file.jpg"); warn "$rc" if "$rc"; # Create the thumbnail using ImageMagick commands # Feel free to set the sequence to anything you like for # thumbnail creation # # For more info, see # http://www.imagemagick.org/script/perl-magick.php $image->Set(quality=>'85'); $image->Set(density=>'72x72'); $image->Set(interlace=>'Line'); $image->Resize(geometry=>'300'); $image->UnsharpMask(radius=>1.3, sigma=>1.1, amount=>40, threshold=>0.05); $image->Crop(geometry=>'125x125+20+20'); $image->Set(bordercolor=>'white'); $image->Border(geometry=>'1x1'); $image->Write($sqfile); undef $image; return 0; } # Create 500x500 image for obscura sub makeObs { my($file,$obsfile) = @_; # Create ImageMagick object my $image = Image::Magick->new; # Read the image into the object, print any errors that occur my $rc = $image->Read("$file.jpg"); warn "$rc" if "$rc"; # Print message to screen my($w,$h) = ($image->Get('columns'),$image->Get('rows')); print "Making $obsfile, original $w x $h.\n"; # Create the gallery image using ImageMagick commands # These can be set to whatever ImageMagick sequence you would # like to use on gallery images. $image->Set(quality=>'85'); $image->Set(density=>'72x72'); $image->Set(interlace=>'Line'); $image->Resize(geometry=>'500x500'); $image->UnsharpMask(radius=>1.3, sigma=>1.1, amount=>40, threshold=>0.05); $image->Write($obsfile); undef $image; return 0; } # Reads image names from index.cat file in the current directory. # Creates thumbnail and smaller display image from original files # in the scale directory. Skips scaled images that already exist sub convertImages { my($file, $title, $tech, $copy, $location); # Open index.cat to get file list open(CAT,"index.cat") or die("Could not open cat file"); # Create scale directory if it does not already exist if(!-d "scale") { mkdir("scale"); } while(<CAT>) { # Clean up newlines chop; # Set variables from the index.cat file. The only one actually used # here is the filename ($file,$title,$tech,$copy,$location)=split /\|/; # Scaled and thumbnail image filenames my($sqfile,$obsfile) = ("scale/$file-sq.jpg","scale/$file-obs.jpg"); # Create thumbnail and small image if(!-e $sqfile) { &makeSq($file,$sqfile); } if(!-e $obsfile) { &makeObs($file,$obsfile); } } close(CAT); } # Parse command line options # Convert images if($ARGV[0] =~ "conv") { print "Converting images...\n"; convertImages(); exit; # Create index file. Arguments are title, location, and date } elsif($ARGV[0] =~ "index") { if($ARGV[1] && $ARGV[2] && $ARGV[3]) { print "Indexing...\n"; makeIndex(); exit; } # Create 400 pixel image for the front page of steveblock.com # Argument is the name of the file to resize } elsif($ARGV[0] =~ "fp") { if($ARGV[1]) { if($ARGV[1] =~ /^.*\.jpg/) { print "Sizing $ARGV[1] for the front page...\n"; makeFP($ARGV[1]); exit; } } } # If nothing else happens, print help print "taimagick v1.2.1 - Image Management\n"; print "Based on taimg v2.0, by Alex Leigh\n"; print "Copyright (c) 2005 Steve Block - scblock at ev-15 dot com\n"; print "Usage: \ttaimagick [conv|index|fp]\n"; print "\tconv - Convert images\n"; print "\tindex \"title\" \"location\" \"date\" - Generate index\n"; print "\tfp filename.jpg - Create image for steveblock.com front page\n";