Skip to content

Commit

Permalink
Warning messages for FIELD_IGNORE tags for writing and for TIFF_SETGE…
Browse files Browse the repository at this point in the history
…T_UNDEFINED for reading added. (#438)
  • Loading branch information
SuLaus authored and rouault committed Oct 13, 2022
1 parent 115e1ae commit 2abc5c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions libtiff/tif_dir.c
Expand Up @@ -503,7 +503,17 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
* for the image's codec then we'll arrive here. This
* happens, for example, when tiffcp is used to convert between
* compression schemes and codec-specific tags are blindly copied.
*
* This also happens when a FIELD_IGNORE tag is written.
*/
if (fip->field_bit == FIELD_IGNORE) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Ignored %stag \"%s\" (not supported by libtiff)",
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
fip->field_name);
status = 0;
break;
}
if(fip->field_bit != FIELD_CUSTOM) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Invalid %stag \"%s\" (not supported by codec)",
Expand Down
6 changes: 3 additions & 3 deletions libtiff/tif_dirinfo.c
Expand Up @@ -64,15 +64,15 @@ static const TIFFFieldArray gpsFieldArray;
static const TIFFField
tiffFields[] = {
{ TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL },
{ TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL },
{ TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "OldSubfileType", NULL },
{ TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL },
{ TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL },
{ TIFFTAG_BITSPERSAMPLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL },
{ TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL },
{ TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL },
{ TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL },
{ TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellWidth", NULL },
{ TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellLength", NULL },
{ TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellWidth", NULL },
{ TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellLength", NULL },
{ TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL },
{ TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL },
{ TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL },
Expand Down
3 changes: 3 additions & 0 deletions libtiff/tif_dirread.c
Expand Up @@ -5386,6 +5386,9 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
switch (fip->set_field_type)
{
case TIFF_SETGET_UNDEFINED:
TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag",
"Defined set_field_type of custom tag %"PRIu16" (%s) is TIFF_SETGET_UNDEFINED and thus tag is not read from file",
fip->field_tag, fip->field_name);
break;
case TIFF_SETGET_ASCII:
{
Expand Down

0 comments on commit 2abc5c6

Please sign in to comment.