I am working on a Kodak CD processor utility to make some use out this mountain of images my wife has built up for me. I have around 100 CD's and I decided I had better write a Perl utility to process them into a more useful block of information. I looked on CPAN and here, but didn't really find much. I am working with some older ( year 2000) Kodak CD's so possibly the format has changed, but I am trying to make everything as generic as possible. So to that end I am seeking some wisdom on how to best provide an interface to some of the methods.
I read the INFO.CD file and get the OrderId and use that for my reference point since the CD is stamped with this it gives some point to refer to in the future if you want to know where the original was. I then get a list of the photos from the disk. This is where my first question lies. I had been saving the images to the HD for processing and archiving, but that lead to redundant archiving since the CD should be the archive. This was also eating up a lot of HD space so I just stored the list and always goes back to the source to do any modifications. Would this be useful as a configuration option, the storing of the files to HD versus going to source that is?
Once I get the list I then process each image with Image::Magick and convert the images to presently predefined sizes. Which brings me to my second question. What would be a good generic interface to this? I am presently toying with this:
sub resize_image {
my ($self,$file) = @_;
my($image, $x);
print "Creating image " . $self->percent . "% the size of $file\n"
+;
$image = Image::Magick->new;
$x = $image->Read($self->source_directory . "/$file");
warn "$x" if "$x";
$x = $image->Resize('geometry' => $self->percent ."%" );
warn "$x" if "$x";
$x = $image->Write($self->output_directory . "/" . $self->prefix .
+ "$file");
warn $x if $x;
}
sub make_various_sizes {
my ($self,$size_list) = @_;
=pod
# size list example
$size_list = [
{ prefix => 'small_', percent => '15' },
{ prefix => 'medium_', percent => '50' },
];
=cut
foreach my $size (@{$size_list}) {
$self->prefix( $size->{'prefix'} );
$self->percent( $size->{'percent'} );
$self->resize_images();
}
}
sub resize_images {
my ($self) = @_;
foreach my $file (@{ $self->{'list'} }) {
$self->resize_image($file);
}
}
It isn't flexible enough though in my opinion if I add it here in one of the code areas or upload it to CPAN. It should provide for, in my opinion, at least the following:
- Default prefix if none is passed, useful for the single image process. What would be some suggested generic prefixes? I was thinking of using percentage break over points.
- Has to allow for suffixes as well. Most batch image processing programs allow for this.
- Method names that make sense. Is the make_various_sizes clear?
- Flush the prefix and percentage after a make_various_sizes in a clean fashion to avoid "mistakes"
Other methods currently store the original image names in an XML configuration file via the XML::Simple module. In the works are XML configuration files that store additional information about the images and at a higher directory level the CD itself. I have rough HTML generators, but I think I can do away with and let the user process the XML or perhaps tie in with some templating module. I don't have much familiarity with the templating modules so that would most likely be a long way off.
I am going to be adding a web interface utility to this to allow for working with existing image stores so any suggestions concerning how people would/are interact(ing) with them currently that might be good to have in here would be help. As for the web interface right now my wife has requested:
- Move
- Email to a friend (single or group)
- Caption (create/edit)
- Title (create/edit)
- Slide Show
What other features might be useful in the core module in general?
What might be a good name for this module?
What modules can be recommended to handle some of this as well so I don't reinvent the wheel? I looked
at some of the existing ones and most of them require creation of the Caption, Titles, etc. in
text files by hand
is there one that allows for a web interface creation and edit process?
If what I have started above is already in a module somewhere please point me in the right direction there as well.
While working on this I also created a nice little email image (well any or all attachments really) extractor that works with mbox style mail stores.
I used it to parse my wife's Win32 Netscape mail.
I will be posting it here once the next release of Mail::MailboxParser since
it should have some Win32 issues corrected in it. Is this something that
should be included in what I described above, or should it be a seperate module (tree)?