Generate png thumbnail

Discussion in 'Perl Misc' started by alexjaquet@gmail.com, Oct 31, 2005.

  1. Guest

    Hi,

    I'm looking for a way to generate png thumbnail from jpg, doe's anyone
    know how do it ?.

    Thanks for it.

    Alexandre Jaquet
     
    , Oct 31, 2005
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Oct 31, 2005
    #2
    1. Advertising

  3. zentara Guest

    On 30 Oct 2005 23:51:31 -0800, wrote:

    >Hi,
    >
    >I'm looking for a way to generate png thumbnail from jpg, doe's anyone
    >know how do it ?.
    >
    >Thanks for it.
    >
    >Alexandre Jaquet


    Run this in the directory and it will do all jpg's.

    #!/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.png';
    $image->Scale(geometry => '100x100');
    $ok = $image->Write($thumb) and warn ($ok);
    undef @$image; #needed if $image is created outside loop
    print "$pic -> $thumb\n";
    }
    __END__


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Oct 31, 2005
    #3
  4. Guest

    Great thanks
     
    , Oct 31, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Øyvind Isaksen

    generate thumbnail on the fly

    Øyvind Isaksen, Nov 12, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    606
    =?Utf-8?B?bmV0cXVhbnQ=?=
    Feb 2, 2006
  2. David Lozzi
    Replies:
    1
    Views:
    518
    john smith
    Feb 1, 2006
  3. Replies:
    0
    Views:
    495
  4. sophie_newbie
    Replies:
    6
    Views:
    809
    Chris Angelico
    Jun 16, 2012
  5. Replies:
    1
    Views:
    173
    Darren Dunham
    Oct 2, 2007
Loading...

Share This Page