繁体   English   中英

当我使用Perl :: Magick的Gratent Extent时,为什么我的图像不在中心?

[英]Why isn't my image in the center when I use Perl::Magick's Extent with Gravity?

我正在尝试使用ImageMagick来扩展图像:

my $image = Image::Magick->new;
open( IMAGE, $filename );
$image->Read( file => \*IMAGE );
close(IMAGE);

$image->Extent( gravity => 'Center', width => 150, height => 150, );

$image->Write( $outfile );

当图像延伸到正确的大小时,它不在中间。 我正确使用这个吗?

更新:

我也试过使用笨重的版本:

$image->Set( Gravity => 'Center' );

但仍然没有好处。 我使用的是6.5.8-10版本。

第二次更新:

在PerlMagick的更新日志中找到了这个:

2009-10-18  6.5.7-0 Cristy  <quetzlzacatenango@image...>
  * Interpret gravity properly for ExtentImage().
#Ok, you need to extent your image upto 100x100 and fill new area by transparent background:

($nx, $ny) = $image->Get('base-columns','base-rows');
$nnx = 50-$nx/2;
$nny = 50-$ny/2;

$image->Extent(geometry=>"100x100-$nnx-$nny", background=>"graya(0%, 0)");

#woohoo!

看起来像一个bug,因为Perl之外的转换工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM