ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: JimYZGuy on May 09, 2019, 11:32:48 AM

Title: Fixing Suspicious Offsets
Post by: JimYZGuy on May 09, 2019, 11:32:48 AM
Phil,
I'm trying to figure out how to do the equivalent in Perl using Image::Exiftool to fix corrupted EXIF data.

This is the command line that fixes things up (and loses some data):
perl exiftool.pl -exif:all= -tagsfromfile @ -exif:all -unsafe -thumbnailimage -F test1.jpg

These are the warnings I'm dealing with that cause WriteInfo to fail:
Warning                         : Suspicious IFD0 offset for Make
Warning                         : Suspicious IFD0 offset for Model
Warning                         : Bad IFD1 directory

I've tried using SetNewValuesFromFile and FixBase => '' but that doesn't seem to help.

Is there a simple recipe for doing the command-line equivalent in Perl?

Thanks for the help.
Title: Re: Fixing Suspicious Offsets
Post by: Phil Harvey on May 09, 2019, 11:42:06 AM
This is the equivalent to the command you mention (except that it doesn't preserve a backup file):

#!/usr/bin/perl -w
use strict;
use Image::ExifTool;

my $file = shift or die "expecting file name\n";

my $et = new Image::ExifTool;

$et->Options(FixBase => '');

$et->SetNewValue('exif:all' => undef);
$et->SetNewValuesFromFile($file, 'exif:all', 'unsafe', 'thumbnailimage');

$et->WriteInfo($file);


- Phil
Title: Re: Fixing Suspicious Offsets
Post by: JimYZGuy on May 09, 2019, 12:43:39 PM
Awesome! Thanks for continuing to provide excellent support!