http://www.perlmonks.org?node_id=480766

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am having a few problems with the following:
use Image::Magick; @dir_names = ("images_small"); opendir(DIR,"output_gif"); foreach (readdir(DIR)) { /^(\d+).*/; $filename = $1; push @file_convert, $filename; } opendir (DIR, "output_gif") or die "$!"; foreach $dir_name (@dir_names) { foreach $file (<@file_convert>) { $filename_orig = "output_gif\/$file.gif"; print "\tOrig = $filename_orig"; $filename_new = "$dir_name\/" . $file . ".gif"; $image = Image::Magick->new; open (IMAGE, "$filename_orig") or die "$!"; $image->Read(file=>\*IMAGE); close (IMAGE); $image->Resize(geometry=>"12.5%"); $image->Trim; $image->Set(page=> '+0,+0'); open (IMAGE2, ">$filename_new") or die "$!"; $image->Write(file=>\*IMAGE2, filename=>$filename_new); close (IMAGE2); } }
the correct filenames are being written to the new directry images_small but the files are empty?