MATLAB Answers

creating a new TIFF tag field ?

19 views (last 30 days)
Geoffrey
Geoffrey on 21 Apr 2016
Answered: steve solomon on 21 Dec 2019
Hi everyone, I would like to create a new Tag entry in TIFF metadata. I tried :
tags.angle_roll = 0.5698;
geotiffwrite('test1.tif', A, R,'TiffTags',tags);
And I get the error :
Expected TiffTags.angle_roll to match one of
these strings:
'Artist', 'Compression', 'Copyright', 'DateTime',
'DocumentName', 'DotRange', 'ExtraSamples',
'FillOrder', 'Group3Options', 'Group4Options',
'HalfToneHints', 'HostComputer', 'ICCProfile',
'ImageDepth', 'ImageDescription', 'InkNames',
'InkSet', 'JPEGColorMode', 'JPEGQuality', 'Make',
'MaxSampleValue', 'MinSampleValue', 'Model',
'NumberOfInks', 'Orientation', 'PageName',
'PageNumber', 'PhotometricInterpretation',
'Photoshop', 'PlanarConfiguration',
'PrimaryChromaticities', 'ReferenceBlackWhite',
'ResolutionUnit', 'RichTIFFIPTC', 'RowsPerStrip',
'SGILogDataFmt', 'SMaxSampleValue',
'SMinSampleValue', 'SToNits', 'Software',
'TargetPrinter', 'Thresholding', 'TileLength',
'TileWidth', 'TransferFunction', 'WhitePoint',
'XMP', 'XPosition', 'XResolution',
'YCbCrCoefficients', 'YCbCrPositioning',
'YCbCrSubSampling', 'YPosition', 'YResolution',
'ZipQuality'
The input, 'angle_roll', did not match any of the
valid strings.
So is it impossible to create a new Tag entry in tif's metadata with matlab ?

  0 Comments

Sign in to comment.

Answers (3)

Geoffrey
Geoffrey on 22 Apr 2016
Well can you put a sample code please, I don't get it.
For instance if I want to add a Metadata field called 'IhateTiffFormat' and I want to put the value 'yes' inside. I tried:
tagperso.IhateTiffFormat = 'yes';
t.setTag(32770, tagperso);
And I get the error :
Error using tifflib
Tag number (32770) is unrecognized by the TIFF
library.
For creating IFD it's so badly explained in matlab help that I don't understand how to use it... Ther is no sample to see how to create one IFD? How to read a subIFD? How to add new tags in a IFD?

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 21 Apr 2016
TIFF does not define its tags by name. TIFF tags are defined by numeric value, with any alphabetic name being for convenience.
To create a new tag, you will need to use TIFF settag() with a tag number 32768 or higher, and it being recommended to avoid the Adobe tags that have become effectively extensions. The alternative is to create a private IFD and put whatever tags one wants in there. What-ever you do you will need to coordinate with whatever has to read the file, since the names of the tags are not stored in the file.

  1 Comment

Geoffrey
Geoffrey on 21 Apr 2016
Thank's a lot I will try this !

Sign in to comment.


steve solomon
steve solomon on 21 Dec 2019
I tried using a tag number 32768 or higher
> setTag(h,32769,'test tag')
and get the error message:
Error using tifflib
Tag number (32769) is unrecognized by the TIFF library.
Error in Tiff/setTag (line 1411)
tifflib('setField',obj.FileID,varargin{:});
it doesn't appear that new tags can be created using settag.

  0 Comments

Sign in to comment.

Sign in to answer this question.