Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5619 closed defect (fixed)

Cannot remove TIFFTAGs

Reported by: afritzler Owned by: Even Rouault
Priority: normal Milestone: 1.11.1
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: gtiff tag
Cc:

Description

If I have an image that gdalinfo says this about:

...
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DOCUMENTNAME=mask.tif
  TIFFTAG_SOFTWARE=GraphicsMagick 1.3.12 2010-03-08 Q8 
...

I'd like to delete those two tags entirely from the TIFF.

import gdal
ds = gdal.Open('x.tif', gdal.GA_Update)
# this does nothing
ds.SetMetadata({})
ds.FlushCache()
# nor does this
ds.SetMetadataItem('TIFFTAG_SOFTWARE', None)
ds.FlushCache()
# this does what you'd expect, sets value to an empty string
ds.SetMetadataItem('TIFFTAG_SOFTWARE', '')
ds.FlushCache()

I'd prefer the tags be removed entirely from the file, not just set to empty.

Change History (3)

comment:1 by Even Rouault, 10 years ago

Component: defaultGDAL_Raster
Keywords: gtiff tag added
Owner: changed from warmerdam to Even Rouault

comment:2 by Even Rouault, 10 years ago

Milestone: 1.11.1
Resolution: fixed
Status: newclosed

Note that the following fix does not "securely" erase previously written values as the TIFF directory gets rewritten at the end of the file, and not in-place. So by examining the content of the file with an hexadecimal editor it is generally possible to recover the values that are going to be unset.

trunk r27590, branches/1.11 r27591 "GTiff: allow unsetting TIFFTAG_SOFTWARE, TIFFTAG_DOCUMENTNAME, etc... by removing them from metadata list or passing None as a value of SetMetadataItem() (#5619)"

comment:3 by Even Rouault, 10 years ago

Note: the comment of r27596 wrongly points to that ticket instead of #5616.

Note: See TracTickets for help on using tickets.