Perl Image :: Imlib2 :: Thumbnail :: Scaled构造函数

时间:2016-06-17 17:37:08

标签: perl cpan imlib2

更新了一堆CPAN模块后,遇到此代码不再运行并向构造函数"提供了大量参数。错误。

use Image::Imlib2::Thumbnail::Scaled;
my $thumbnail= Image::Imlib2::Thumbnail::Scaled->new({
  sizes => [
    { width => 300, height => 300, name => 'large' },
    { width => 240, height => 240, name => 'medium' },
    { width => 150, height => 150, name => 'small' },
  ]
});

1 个答案:

答案 0 :(得分:1)

最新版本的Image :: Imlib2 :: Thumbnail :: Scaled(0.05)将构造函数从版本0.01 / 0.02 / 0.03 / 0.04更改为接受哈希,现在在hashref上失败,因此任何以前的代码都需要更新或它会失败。

Ver .05文档: http://search.cpan.org/~srchulo/Image-Imlib2-Thumbnail-Scaled-0.05/lib/Image/Imlib2/Thumbnail/Scaled.pm

Ver .04文档: http://search.cpan.org/~srchulo/Image-Imlib2-Thumbnail-Scaled-0.04/lib/Image/Imlib2/Thumbnail/Scaled.pm

解决我的问题:

my $thumbnail= Image::Imlib2::Thumbnail::Scaled->new({
  sizes => [
    { width => 300, height => 300, name => 'large' },
    { width => 240, height => 240, name => 'medium' },
    { width => 150, height => 150, name => 'small' },
  ]
});

更改为:

my $thumbnail= Image::Imlib2::Thumbnail::Scaled->new(
  sizes => [
    { width => 300, height => 300, name => 'large' },
    { width => 240, height => 240, name => 'medium' },
    { width => 150, height => 150, name => 'small' },
  ]
);

(删除{和})