Perl Image::Imlib2::Thumbnail::Scaled Uneven number of arguments to constructor

After updating a bunch of CPAN modules, ran into this code no longer functioning and throwing an "Uneven number of arguments to constructor" error.

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' },
  ]
});

Upvotes: 1

Views: 57

Answers (1)

The newest version of Image::Imlib2::Thumbnail::Scaled (0.05) changed the constructor from versions 0.01/0.02/0.03/0.04 to accept hash and now fails on hashref, so any previous code needs to be updated or it will fail.

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

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

To fix my problem:

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' },
  ]
});

Changed to:

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' },
  ]
);

(Removed { and } )

Upvotes: 1

Related Questions