sub PDFtoIMAGE { foreach my $a (keys %dir) { my $file = $a; printf "$file\n"; if($file=~/\.pdf/ || $file=~/\.PDF/) { my $Img = Image::Magick->new; $Img->Set(density => '300'); print "reading: $file\n"; $Img->read("$path$file"); my ($width, $height, $size, $format)=$Img->Ping("$path$file"); print "$width, $height, $size, $format\n"; $Img->Extent(width=>$width,height=>$height); $file=~s/\.pdf/\.jpg/; $file=~s/\.PDF/\.jpg/; print "creating: $file\n"; $Img->Write("png24:$path$file"); print "created: $file\n"; } } }