in reply to Using ImageMagick effectively

According to my ubuntu 14.04 OS, I have this installed.

Do you also have the perlmagick package (http://packages.ubuntu.com/trusty/perlmagick) installed? Is the perl in your PATH the system perl or a custom build?

Replies are listed 'Best First'.
Re^2: Using ImageMagick effectively
by Aldebaran (Curate) on Sep 26, 2014 at 02:48 UTC

    Installing perlmagick was what I needed. I've written a routine that iterates through the images folder, but I fail to create and assign the object correctly:

    sub resize_images { use 5.010; use Path::Class; use Image::Magick; my ($rvars) = shift; my %vars = %$rvars; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ my $image = Image::Magick->new; $image->ReadImage($_); $x = $image->Get('filesize'); say "$_ has filesize of $x"; } }

    Output:

    Screenshot from 2014-08-21 13:10:18.png has filesize of Screenshot from 2014-09-25 17:14:08.png has filesize of Screenshot from 2014-08-21 13:22:42.png has filesize of zbears.jpg has filesize of . has filesize of .. has filesize of yjj.jpg has filesize of

    Fishing for tips....

      You need to prepend the directory to the filename (see readdir), and you can check if the read was successful:
      my $dir = $vars{to_images}; ... my $err = $image->ReadImage("$dir/$_"); warn "$err" if $err;
      Also, might be better to filter out the non-image files before passing to Image::Magick.