sub convert_images { my ($array, $start_directory) = ($_[0], $_[1]); foreach my $picture (@$array) { # read the image via a filehandle my $image = Image::Magick->new; open(IMAGE, "<$start_directory\\$picture") || die "Unable to open image: $!"; $image->Read(file=>\*IMAGE) || die "Unable to read image: $!"; close(IMAGE); # resize the image to the correct width and height $image->Resize(geometry=>'450X300') || die "Unable to resize image: $!"; # write the image back to disk $image->Write(filename=>"$picture", compression=>'None') || die "Unable to write image: $!"; } }