I am attempting to change the BlackLevelRepeatDim on a Tiff file but am not seeing much success :( . I have found the Protected keyword and when set to 1 it leads me to believe the values are being written out but when I try and query them there is nothing there.
Any help would be awesome!
Here is the code that I am working with
use strict;
use warnings;
use Image::ExifTool qw(:Public);
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue('SubIFD:BlackLevelRepeatDim', '1 1', Protected=>1);
my $result = $exifTool->WriteInfo($ARGV[1]);
my $info = ImageInfo($ARGV[1],'SubIFD:BlackLevelRepeatDim' );
foreach (keys %$info) {
print "$_ => $$info{$_}\n";
}
Best,
Austin
Hi Austin,
If $result is 1, then the file was changed. If it is 2, then nothing changed. This will happen if the file doesn't contain a SubIFD, since ExifTool won't create a SubIFD.
What is the value of $result?
- Phil
Thank you so much for your fast response! The result is showing up as 2 but there is a SubIFD in the file :(. I am also not tied to Perl if there is a simpler way to do it on the command line I am open to that as well. Thanks again for your help!
[ExifTool] ExifToolVersion : 10.13
[System] FileName : IMG_0107_3.tif
[System] FileSize : 12 MB
[System] FileModifyDate : 2016:03:30 09:25:04-06:00
[System] FileAccessDate : 2016:03:30 09:25:04-06:00
[System] FileCreateDate : 2016:03:30 09:14:05-06:00
[System] FilePermissions : rw-rw-rw-
[File] FileType : TIFF
[File] FileTypeExtension : tif
[File] MIMEType : image/tiff
[File] ExifByteOrder : Little-endian (Intel, II)
[IFD0] ImageWidth : 1274
[IFD0] ImageHeight : 960
[IFD0] BitsPerSample : 16 16 16 16 16
[IFD0] Compression : Uncompressed
[IFD0] PhotometricInterpretation : RGB
[IFD0] FillOrder : Normal
[IFD0] ImageDescription : IDL TIFF file
[IFD0] Make : Test
[IFD0] Model : Test
[IFD0] StripOffsets : (Binary data 12952 bytes, use -b option to extract)
[IFD0] Orientation : Horizontal (normal)
[IFD0] SamplesPerPixel : 5
[IFD0] RowsPerStrip : 3
[IFD0] StripByteCounts : (Binary data 7999 bytes, use -b option to extract)
[IFD0] XResolution : 100
[IFD0] YResolution : 100
[IFD0] PlanarConfiguration : Planar
[IFD0] ResolutionUnit : inches
[IFD0] Software : v1.5.8
[IFD0] ModifyDate : 2016:03:02 16:31:58
[XMP-x] XMPToolkit : Image::ExifTool 10.13
[XMP-tiff] BitsPerSample : 16, 16
[XMP-tiff] Compression : Uncompressed
[XMP-tiff] ImageHeight : 960
[XMP-tiff] ImageWidth : 1280
[XMP-tiff] PhotometricInterpretation : BlackIsZero
[XMP-tiff] PlanarConfiguration : Chunky
[XMP-tiff] SamplesPerPixel : 1
[ExifIFD] ExposureTime : 1/926
[ExifIFD] FNumber : 2.8
[ExifIFD] ExposureProgram : Program AE
[ExifIFD] ISOSpeed : 100
[ExifIFD] ExifVersion : 0230
[ExifIFD] DateTimeOriginal : 2016:03:02 16:31:58
[ExifIFD] ComponentsConfiguration : Y, Cb, Cr, -
[ExifIFD] MeteringMode : Average
[ExifIFD] FocalLength : 5.5 mm
[ExifIFD] FlashpixVersion : 0100
[ExifIFD] ColorSpace : Uncalibrated
[ExifIFD] FocalPlaneXResolution : 266.6666667
[ExifIFD] FocalPlaneYResolution : 266.6666667
[ExifIFD] FocalPlaneResolutionUnit : mm
[ExifIFD] SerialNumber : 1545076
[Composite] Aperture : 2.8
[Composite] ImageSize : 1274x960
[Composite] Megapixels : 1.2
[Composite] ScaleFactor35efl : 7.2
[Composite] ShutterSpeed : 1/926
[Composite] CircleOfConfusion : 0.004 mm
[Composite] FOV : 48.7 deg
[Composite] FocalLength35efl : 5.5 mm (35 mm equivalent: 39.8 mm)
[Composite] HyperfocalDistance : 2.60 m
use strict;
use warnings;
use Image::ExifTool qw(:Public);
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue('SubIFD:BlackLevelRepeatDim', '1 1', Protected=>1);
my $result = $exifTool->WriteInfo($ARGV[1]);
print $result;
my $info = ImageInfo($ARGV[1],'SubIFD:BlackLevelRepeatDim' );
foreach (keys %$info) {
print "$_ => $$info{$_}\n";
}
There is no SubIFD in the output that you posted. The only IFD's are IFD0 and ExifIFD.
From the command line it would be: exiftool -subifd:blacklevelrepeatdim="1 1" IMG_0107_3.tif
but that will give the same result as your script.
- Phil
That makes sense, but I am still confused then as to what the best method is for adding the BlackLevelRepeatDim tag, and any other for that matter, to my file. Do I first need to declare it some how?
Thanks again for your help.
-Austin
Hi Austin,
BlackLevelRepeatDim has a specific meaning for the interpretation of an image in a TIFF file (which is why this tag is protected by ExifTool). It doesn't make much sense to use it for another purpose, but you could (if you really wanted) write it to any IFD you want, for example:
exiftool -ifd0:blacklevelrepeatdim="1 1" IMG_0107_3.tif
- Phil
That worked!!!
The reason that I am trying to edit that tag, among others, is simply because I copy / edited some remote sensing images, the software that I am using did not carry the exif tags through :(. I was wondering does this also work for xmp tags? I tried the same syntax on the following tag but was not able to get it to be go.
[XMP-Camera] BandName : Red
-Austin
Hi Austin,
A tag must be defined to be able to write it. EXIF tags (https://exiftool.org/TagNames/EXIF.html) have a preferred IFD (Group column in the EXIF Tags documentation) that they are written unless otherwise specified.
XMP Tags (https://exiftool.org/TagNames/XMP.html) may only be written to the group for which they are defined.
Your XMP-Camera:BrandName tag is not known to ExifTool, so to be able to write this you must create a user-defined XMP tag. See the sample config file (https://exiftool.org/config.html) for examples of how to do this.
- Phil
Hi Phil,
I was able to get the configuration file all setup and things are running smoothly now. Thanks for all your help!
-Austin