my $image = Image::Magick->new; foreach my $pic (@pics){ my $ok; $ok = $image->Read($pic) and warn ($ok); $image->Scale(geometry => '100x100'); $ok = $image->Write($thumb) and warn ($ok); # this is the key line undef @$image; #needed if $image is created outside loop