ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: frank on June 02, 2020, 10:48:27 AM

Title: Stripping all values works via command line, but not with API
Post by: frank on June 02, 2020, 10:48:27 AM
Hi,

I'm using the code below:

use strict;
use warnings;
use Image::ExifTool qw(:Public);

# don't buffer
BEGIN { $| = 1 }

my $path = $ARGV[0];
my $temp_path = $ARGV[1];

print "set.pl\n";
print "path: $path\n";
print "temp_path: $temp_path\n";

my $exifTool = new Image::ExifTool;
$exifTool->Options(IgnoreMinorErrors => 1);
my $info = $exifTool->ImageInfo($path);

$exifTool->SetNewValue( "*" );

my $success = 1;

if( $temp_path eq "<none>" ) {
    $success = $exifTool->WriteInfo($path);
} else {
    $success = $exifTool->WriteInfo($path, $temp_path);
}

if( $success ) {
    exit(0);
} else {
   
    my $error_message = $exifTool->GetValue('Error');
    print "exiftool error message: $error_message";
    exit(1);
}


to remove all tags from an image file. It works great for some files, but not for others.

In particular, for a load of Sony RAW files, e.g. SR2, it just does nothing and returns no error.

Running the exiftool:

exiftool -all= /Users/frankreiff/Desktop/temp_sample_files/quick_test/RAW_SONY_R1.SR2


command line works just fine.

Unfortunately the image is too large to attach it here.

What am I doing wrong?

Thanks so much for your help and for your time.

Best regards,

Frank
Title: Re: Stripping all values works via command line, but not with API
Post by: StarGeek on June 02, 2020, 10:58:30 AM
I can't comment what might be wrong with the code but I need to point out that if you strip all data with -all= from a RAW image, you quite possibly render the image unviewable.  See the capitalized text under FAQ #7 (https://exiftool.org/faq.html#Q7) and FAQ #8c (https://exiftool.org/faq.html#Q8)
Title: Re: Stripping all values works via command line, but not with API
Post by: frank on June 02, 2020, 11:37:21 AM
Thanks. I had already noticed that deleting the color space information has strange side effects.

It could well be that all the formats that it does not work for are TIFF-based.

I have tried modifying the code:

$exifTool->SetNewValue( "EXIF:*" );
$exifTool->SetNewValue( "GPS:*" );


but that also does not modify anything and generates no errors.

Is there a special TIFF option that needs to be set?

I'm attaching a (more reasonably sized) NEF file (TIFF-based according to your table) that also generates no errors and does not get changed.

Thanks again for your help!
Title: Re: Stripping all values works via command line, but not with API
Post by: Phil Harvey on June 02, 2020, 03:28:13 PM
Hi Frank,

I get this from the command line with the file you uploaded:

> exiftool -all= -a __19d50_5000_0011.NEF
Warning: [minor] Can't delete IFD0 from NEF - b.nef
Warning: [minor] Can't delete ExifIFD from NEF - b.nef
Warning: [minor] Can't delete MakerNotes from NEF - b.nef
    0 image files updated
    1 image files unchanged


Note that the "minor" starts with a lower-case "m", which means that the behaviour will not change when -m is used.  So -all= has no effect on this file (with ExifTool 11.99).  Good thing too because as StarGeek said, deleting all metadata from a raw file isn't a good idea.

- Phil

Title: Re: Stripping all values works via command line, but not with API
Post by: frank on June 03, 2020, 10:06:04 AM
Hi,

Thanks for the reply. I was a bit lost in the fog of war and concentrating on why it was failing rather than whether it should be done at all. I've done some more experimenting and I've managed to remove tag groups where it actually makes sense fine from all the files.

Best regards,

Frank