Author Topic: Stripping all values works via command line, but not with API  (Read 231 times)

frank

  • Newbie
  • *
  • Posts: 8
Hi,

I'm using the code below:

Code: [Select]
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:

Code: [Select]
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3955
Re: Stripping all values works via command line, but not with API
« Reply #1 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 and FAQ #8c
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

frank

  • Newbie
  • *
  • Posts: 8
Re: Stripping all values works via command line, but not with API
« Reply #2 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:

Code: [Select]
$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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: Stripping all values works via command line, but not with API
« Reply #3 on: June 02, 2020, 03:28:13 PM »
Hi Frank,

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

Code: [Select]
> 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

frank

  • Newbie
  • *
  • Posts: 8
Re: Stripping all values works via command line, but not with API
« Reply #4 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