Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have an image uploader which I'm using (cgi) to create instant thumbnails of my images. I can get most static GIF files and jpg/jpeg and bmp files to work properly. The problems come in when 1) the filename contains something not letters or numbers like a hypen - and 2) animated gifs don't produce thumbnails.

There are probably more characters other than the hyphen that will prevent thumbnailing, so there might be a problem with my regex or something. Can you take a look at the snippet below and see how I can correct it to allow any legit filename?

I know it's crazy to think an animated gif will produce a thumbnail, but is it possible in any way to capture the first frame as a thumbnail or are animations totally out of the picture here?

$localfile = $filename; $localfile =~ m/(.*)\.(.*)/; $newfilename = "generated_thumbs/$1.png"; $x = $image->Write($newfilename);

janitored by ybiC: Retitle from "few Image::Magick questions" for searchability

Replies are listed 'Best First'.
Re: few Image::Magick questions
by PodMaster (Abbot) on Feb 22, 2004 at 06:09 UTC
    See ICON TO BMP (using Image::Magick)

    Image::Magick should let you get at each individual "frame" and manipulate it any way you wish.

    As for the filename, I don't see why a hyphen would make any kind of impact, but anyway, I'd use File::Basename.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.