Stripping all values works via command line, but not with API

Started by frank, June 02, 2020, 10:48:27 AM

Previous topic - Next topic

frank

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

StarGeek

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 and FAQ #8c
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

frank

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!

Phil Harvey

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

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

frank

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