Extracting PreviewImage with GetValue

Started by Archive, May 12, 2010, 08:53:54 AM

Previous topic - Next topic

Archive

[Originally posted by copperleaf on 2006-06-06 19:33:35-07]

I'm trying to extract the PreviewImage from within a perl script. Here is a snippet:
Code:
   my $exifTool = new Image::ExifTool;
    $exifTool->Options(PrintConv => 0);
    my $info = $exifTool->ImageInfo($src);
    my $blob = $exifTool->GetValue('PreviewImage', ' Raw');
    open(OUT, ">preview.jpg");
    binmode(OUT);
    syswrite(OUT, $$blob);
    close(OUT);
What I get in my output file is the string "Binary data 25755 bytes". How do I get to the actual binary data?

TIA,
Bill

Archive

[Originally posted by copperleaf on 2006-06-06 19:47:48-07]

I've also tried this. (without dereferencing $blob).

Code:
my $exifTool = new Image::ExifTool;
$exifTool->Options(PrintConv => 0);
my $info = $exifTool->ImageInfo($src);
my $blob = $exifTool->GetValue('PreviewImage', 'Raw');
open(OUT, ">preview.jpg");
binmode(OUT);
syswrite(OUT, $blob);
close(OUT);

Archive

[Originally posted by exiftool on 2006-06-06 22:40:42-07]

Hi Bill,

This can be solved in two ways:

Code:
# 1) Set the "Binary" option to force large binary data blocks to be extracted:
$exifTool->Options(Binary => 1);

# or 2) extract the PreviewImage tag explicitly:
my $info = $exifTool->ImageInfo($src,'PreviewImage');

- Phil