Sometimes you need a way to extract all images in a PDF but then you have a directory of files and you need to extract them iteratively.
Prerequisites:
1. Install Cygwin or linux environment with Perl support.
2. Install ImageMagick.
3. Install GhostScript.
Afterward run the following script:
#!/bin/perl
my $directory = $ARGV[0];
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR))
{
if ($file =~ m/.pdf/)
{
my $newfile = $file;
$newfile =~ s/.pdf/_%01d.jpg/;
print "Processing " . $file . " ; newfilename: " . $newfile . "...n";
`convert -density 150 $file $newfile`;
}
}
How to invoke:
scriptname path_to_pdf_files
Cheers.
