Hi all!
Is it possible to find out TIFF version with ExifTool?
I read this with Jhove:
RepresentationInformation: C:\#####\0487.tif
ReportingModule: TIFF-hul, Rel. 1.8 (2017-05-11)
LastModified: 2019-05-27 09:40:03 EEST
Size: 25558024
Format: TIFF
Version: 5.0
Status: Well-Formed and valid
Jhove is not an option for us... I really can't see from Jhove results that where is that information coming from.
Thanks in advance :)
This information is not stored in a TIFF file, so they must be deriving the version from the values of other tags. If you knew what they were doing, you could create a user-defined Composite tag to do this in ExifTool.
- Phil
According to http://jhove.openpreservation.org/modules/tiff/#profiles jhove takes the existence of several tags as indication of TIFF version
Thanks for that olball.
I may have made a config file that will determine the version of the tiff file. The only trouble is that I can't truly test it because none of the tiffs I have seem to be version 5 or 6. Many of these tags, such as EXIF:ColorMap (for version 5) and EXIF:DotRange (ver 6) are not writable with exiftool so I can't create one.
I'm searching around online for a sample file but if anyone already has a file or link to share, let me know.
Hmmm... Maybe I'm reading that link wrong. Is the existence of all those tags required for version 5/6 or does the simple presence of one on the list required? For example, a tiff with EXIF:Artist and nothing else mean it's a version 5? Is a file with just EXIF:Copyright and nothing else a version 6?
I went ahead and installed jhove and used it to test files. But there is definitely something missing, as jhove says some files I have are version 6 but don't seem to pass any of the criteria laid out in that link. Except for possibly this line:
QuoteThe presence of a data type 6 (SBYTE), 7 (UNDEFINED), 8 (SSHORT), 9 (SLONG), 10 (SRATIONAL), 11 (FLOAT), or 12 (DOUBLE) indicates version 6.0
I'm not quite sure what that means as it doesn't refer to
EXIF:DataType as all the other tags give the tag id.
It's also weird because the files in question are uncompressed, which seems to me that they would be more likely not to be a newer version. The same file with compression (both LZW and Deflate) are 5.0
Hmmm... It looks like there are a few other tags in the uncompressed that jhove says is 6.0
EXIF:PageNumber,
EXIF:MinSampleValue, and
EXIF:MaxSampleValue.
Here's the config file I made, slightly broken at the moment as it will misidentify some 6.0 files as 5.0.
# Checks if at least one the values passed are defined.
sub has_defined {
for my $i ( @_ ) {
return 1 if defined $i;
}
return 0;
}
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
TiffVersion => {
Require => {
0 => 'FileType'
},
Desire => {
# Version 5
1 => 'EXIF:Artist', # Artist (315/0x013b)
2 => 'EXIF:ColorMap', # ColorMap (320/0x0140)
3 => 'EXIF:ModifyDate', # DateTime (306/0x0132) Called DateTime by EXIF spec, ModifyDate by exiftool
4 => 'EXIF:HostComputer', # HostComputer (316/0x013c)
5 => 'EXIF:SubfileType', # NewSubfileType (254/0x00fe) Called NewSubfileType by TIFF spec, SubfileType by exiftool
6 => 'EXIF:Predictor', # Predictor (317/0x013d)
7 => 'EXIF:PrimaryChromaticities', # PrimaryChromaticities (319/0x013f)
8 => 'EXIF:Software', # Software (305/0x0131)
9 => 'EXIF:WhitePoint', # WhitePoint (318/0x013e)
# Version 6
10 => 'EXIF:Copyright', # Copyright (33432/0x8298)
11 => 'EXIF:DotRange', # DotRange (336/0x0150)
12 => 'EXIF:ExtraSamples', # ExtraSamples (338/0x0152)
13 => 'EXIF:HalftoneHints', # HalftoneHints (321/0x0141)
14 => 'EXIF:InkNames', # InkNames (333/0x014d)
15 => 'EXIF:InkSet', # InkSet (332/0x014c)
16 => 'EXIF:JPEGACTables', # JPEGACTables (521/0x0209)
17 => 'EXIF:JPEGDCTables', # JPEGDCTables (520/0x0208)
18 => 'EXIF:ThumbnailOffset', # JPEGInterchangeFormat (513/0x0201)
19 => 'EXIF:ThumbnailLength ', # JPEGInterchangeFormatLength (514/0x0202)
20 => 'EXIF:JPEGLosslessPredictors', # JPEGLosslessPredictors (517/0x0205)
21 => 'EXIF:JPEGPointTransforms', # JPEGPointTransforms (518/0x0206)
22 => 'EXIF:JPEGProc', # JPEGProc (512/0x0200)
23 => 'EXIF:JPEGRestartInterval', # JPEGRestartInterval (515/0x0203)
24 => 'EXIF:JPEGQTables', # JPEGQTables (519/0x0207)
25 => 'EXIF:NumberofInks', # NumberOfInks (334/0x014e)
26 => 'EXIF:ReferenceBlackWhite', # ReferenceBlackWhite (532/0x0214)
27 => 'EXIF:SampleFormat', # SampleFormat (339/0x0153)
28 => 'EXIF:SMinSampleValue', # SMinSampleValue (340/0x0154)
29 => 'EXIF:SMaxSampleValue', # SMaxSampleValue (341/0x0155)
30 => 'EXIF:TargetPrinter', # TargetPrinter (337/0x0151)
31 => 'EXIF:TileLength', # TileLength (323/0x0143)
32 => 'EXIF:TileOffsets', # TileOffsets (324/0x0144)
33 => 'EXIF:TileWidth', # TileWidth (322/0x0142)
34 => 'EXIF:TileByteCounts', # TileByteCounts (325/0x0145)
35 => 'EXIF:TransferRange', # TransferRange (342/0x0156)
36 => 'EXIF:YCbCrCoefficients', # YCbCrCoefficients (529/0x0211)
37 => 'EXIF:YCbCrPositioning', # YCbCrPositioning (531/0x0213)
38 => 'EXIF:YCbCrSubSampling', # YCbCrSubSampling (530/0x0212)
# Other tags to check
39 => 'EXIF:PhotometricInterpretation', # PhotometricInterpretation (262/0x0106)
40 => 'EXIF:Compression', # Compression (259/0x0103)
},
ValueConv => q{
if ($val[0] ne 'TIFF') {
return undef;
}
if ( $val[39]=~/^(?:C(?:IELab|MYK)|YCbCr)$/ or $val[40] eq 'JPEG (old-style)' or has_defined(@val[10..38]) ) {
return '6.0';
}
if ($val[39]=~/^(?:Transparency Mask|RGB Palette)$/ or $val[40] eq 'LZW' or has_defined(@val[1..9]) ) {
return '5.0';
}
return '4.0';
},
},
},
);
# A couple of shortcuts to test for the existance of certain tags
%Image::ExifTool::UserDefined::Shortcuts = (
TiffVersion5Tags => ['EXIF:Artist','EXIF:ColorMap','EXIF:ModifyDate','EXIF:HostComputer','EXIF:SubfileType','EXIF:Predictor','EXIF:PrimaryChromaticities','EXIF:Software','EXIF:WhitePoint'],
TiffVersion6Tags => ['EXIF:Copyright', 'EXIF:DotRange', 'EXIF:ExtraSamples', 'EXIF:HalftoneHints', 'EXIF:InkNames', 'EXIF:InkSet', 'EXIF:JPEGACTables', 'EXIF:JPEGDCTables', 'EXIF:ThumbnailOffset', 'EXIF:ThumbnailLength ', 'EXIF:JPEGLosslessPredictors', 'EXIF:JPEGPointTransforms', 'EXIF:JPEGProc', 'EXIF:JPEGRestartInterval', 'EXIF:JPEGQTables', 'EXIF:NumberofInks', 'EXIF:ReferenceBlackWhite', 'EXIF:SampleFormat', 'EXIF:SMinSampleValue', 'EXIF:SMaxSampleValue', 'EXIF:TargetPrinter', 'EXIF:TileLength', 'EXIF:TileOffsets', 'EXIF:TileWidth', 'EXIF:TileByteCounts', 'EXIF:TransferRange', 'EXIF:YCbCrCoefficients', 'EXIF:YCbCrPositioning', 'EXIF:YCbCrSubSampling'],
);
#------------------------------------------------------------------------------
1; #end
That's looking pretty good. The part about the data type is the format of the value. The only way you see that with ExifTool is with the -v2 output. Unfortunately there is no way to check this in a user-defined tag.
- Phil
Ah, so it basically isn't possible to detect the TIFF version with 100% accuracy with exiftool. Some version 6s will be reported incorrectly.
Oh well, it made for a fun project for the day.
Wow! This was really helpful. Thanks to you guys :)
This information is mandatory in MIX. So I guess we will try to that check our selves with rules that you already StarGeek wrote OR look at the files once that our devices/softwares create and then "hardcode" a rule which we would use to write this information to sidecard-XML which has metadata about the creation of the file (MIX).
Thanks once again!
I could think about adding a feature to allow access to the TIFF format of each tag. This wouldn't make sense for many information types, but in the past there would have been some use for this feature.
- Phil
Edit: Ah. But this wouldn't help much here because you would need to check the format codes of ALL tags, which would be a pain, plus all IFD's too (for which ExifTool doesn't even generate a tag). So the only solution would be a dedicated ExifTool feature to determine the TIFF version, which I think wouldn't be of use to many people.
Edit2: Turns out it was very easy to add support for accessing the tag formats, so I will add this anyway as an undocumented feature in the next release (the format will be accessible as the family 6 group name -- shhh).
Edit3: Along with this new undocumented feature, I can add a new variable that allows you to easily check for the presence of a specific TIFF format type. I've attached a modified version of StarGeek's config file which updates the TiffVersion tag to include a complete test for TIFF format types with ExifTool 11.50 or later. It even tests the format types of unknown and IFD tags. The command will look like this:
exiftool -config tiff_version.config -api saveformat -tiffversion FILE
Very cool. Now I wish I had a use for it
Version 11.50 with the new SaveFormat option is now available. It also includes tiff_version.config in the full distribution.
- Phil
Wow! This is first class service - Thank you all. I will hand this information out to my software developer!
Hi guys i have a little question:
Can i put some Tags and Comments behind a TIF-files with this software? As example some informations what is inside the file or something like that. Because I want to put some informations behind the file, that I can see what kind of picture it is.
Thanks in advance for a feedback
Hi Melvin,
You can put metadata into a TIFF file with ExifTool. I don't know what you mean by "behind".
- Phil
P.S. I'll probably split this into a separate topic in the "Newbies" section.