I personally believe that there are tons of better, more reliable, and format-specific extractors of images for "container" files like pdf, or (those damned) pps, etc.: either free (for one of the two acceptations of the word) or not. But yesterday I was in a quick need of extracting the jpeg images contained in one such file, so I quickly checked JPEG @ Wikipedia for the headers's markers and I concocted up the latter, possibly complete of some minimal YAGNI (I know I shouldn't) for future development: it worked for me!

#!/usr/bin/perl use strict; use warnings; use 5.010; use open IO => ':raw'; use File::Basename; my $progname; BEGIN { ($progname) = fileparse $0, qr/\.pl/i; } local $/; my %cnt; while (<>) { while ( /(\xFF\xD8 .*? \xFF\xD9)/xsg ) { for my $name ($ARGV . ++$cnt{$ARGV} . '.jpeg') { open my $fh, '>', $name or die "Can't open `$name': $!\n"; warn "[$progname] Creating `$name'\n"; print $fh $1; } } } __END__
If you can't understand the incipit, then please check the IPB Campaign.