How can I resize an image to fit area with Image::Magick?

拟墨画扇 提交于 2020-01-02 03:47:25

问题


From command line with imagemagick, you can use:

convert dragon.gif -resize 64x64^ -gravity center -extent 64x64 fill_crop_dragon.gif

to resize and then crop an image so that it fills the area as much as possible.

How do I do this from Perl's Image::Magick?


回答1:


#!/usr/bin/perl

use strict;
use warnings;

use Image::Magick;

my $image = Image::Magick->new;
$image->read('test.jpg');

$image->Set( Gravity => 'Center' );
$image->Resize( geometry => '64x64' );
$image->Extent( geometry => '64x64' );
$image->Write( 'test-out.jpg' );

See the PerlMagick documentation.



来源:https://stackoverflow.com/questions/890925/how-can-i-resize-an-image-to-fit-area-with-imagemagick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!