Question

I am trying to change the value of a tag from a TIFF object in my matlab code. I keep getting this error:

Error using tifflib
Tag number (273) is unrecognized by the TIFF library.

Error in Tiff/setTag (line 1146)
                    tifflib('setField',obj.FileID, ...

The code I am using is included below:

fname='C:\FileLocation\pcd144_012.tif';
t=Tiff(fname,'r+');
t.getTag('StripOffsets')
t.setTag('StripOffsets',[8, 16392])

Why is it I can get the tag and see it, but cannot set the tag to a different value?

Here is a link to the tiff I am working with:

Tiff Data

Was it helpful?

Solution

I think that you're out of luck with this approach. The setTag methods are mostly used when building a TIFF from scratch. My guess is that the 'StripOffsets' field is not modifiable. Keep in mind that these tools are designed for the normal case of non-broken image files and that changing this field in such cases would either break the file or necessitate re-encoding of the data most of the time. The function should give better feedback (documentation for the TIFF could be better in general) so you might still contact The MathWorks to let them know about this.

As far as finding a way to edit these tags/fields, you might look for and try out some TIFF tag viewer/editor programs to see if they might do it. Otherwise it may come down to parsing the header yourself to find the relevant bytes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top