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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Batch Image Processing
by davorg (Chancellor) on Aug 09, 2006 at 13:35 UTC

    Take your pick:

    Those are the most commonly used ones. There are almost certainly others that I've missed. It's usually worth searching at CPAN before asking questions like that here.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Batch Image Processing
by zentara (Cardinal) on Aug 09, 2006 at 16:14 UTC
    Here is an example using ImageMagick, which will do all jpg's in a directory, naming them with a -t
    #!/usr/bin/perl use warnings; use strict; use Image::Magick; my $image = Image::Magick->new; umask 0022; my @pics= <*.jpg>; foreach my $pic (@pics){ my ($picbasename) = $pic =~ /^(.*).jpg$/; my $ok; $ok = $image->Read($pic) and warn ($ok); my $thumb = $picbasename . '-t.jpg'; $image->Scale(geometry => '100x100'); $ok = $image->Write($thumb) and warn ($ok); undef @$image; #needed if $image is created outside loop print "$pic -> $thumb\n"; }

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Batch Image Processing
by talexb (Chancellor) on Aug 09, 2006 at 21:36 UTC

    And if you're on Unix/Linux, convert has always worked well for me -- I build web picture galleries from a script that calls convert: it scales pictures to a specific size, as well as creating thumbnails, individual web pages and a table of contents. Simple stuff.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      I'm sure you already know, but convert is one of the command line tools that are part of Image Magick. We use convert together with composite to add watermarks. Cool tools!

        I did know that -- but if all you want to do is resize an image, getting Perl to build a command line for convert can be enough to get the job done.

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds