Stretch, resize, or thumbnail an image using Perl

后端 未结 2 613
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 05:55

How can I stretch or resize an image (of any format) using a Perl script?

相关标签:
2条回答
  • 2021-02-06 06:43

    You could use Image::Resize.

    0 讨论(0)
  • 2021-02-06 06:54

    I'd recommend Image::Imlib2... if you can install imlib2 on your machine

    See documentation: Image::Imlib2

    use Image::Imlib2;
    
    # load image from file
    my $image = Image::Imlib2->load("in.png");
    
    # get some info if you want
    my $width  = $image->width;
    my $height = $image->height;
    
    # scale the image down to $x and $y
    # you can set $x or $y to zero and it will maintain aspect ratio
    my $image2 = $image->create_scaled_image($x,$y);
    
    # save thumbnail to file
    $image2->save("out.png");
    

    You might also be interested in Image::Imlib2::Thumbnail, if you can not install imlib2 have a look at Image::Magick

    0 讨论(0)
提交回复
热议问题