From: dirk Date: Sat, 15 Mar 2014 10:49:26 +0000 (+0000) Subject: Added tiff:ignore-tags to ignore specific tags. X-Git-Tag: 7.0.1-0~2582 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63dda21d61ea58ffff08ad985230fe73b54af241;p=imagemagick Added tiff:ignore-tags to ignore specific tags. --- diff --git a/coders/tiff.c b/coders/tiff.c index 63bdb43a8..d2e4f563c 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1844,6 +1844,72 @@ RestoreMSCWarning static TIFFExtendProc tag_extender = (TIFFExtendProc) NULL; +static void TIFFIgnoreTags(TIFF *tiff) +{ + char + *q; + + const char + *p, + *tags; + + Image + *image; + + TIFFFieldInfo + *ignore; + + register ssize_t + i; + + size_t + count; + + image=(Image *)TIFFClientdata(tiff); + tags=GetImageArtifact(image,"tiff:ignore-tags"); + if (tags == (const char *) NULL) + return; + count=0; + p=tags; + while (*p != '\0') + { + while ((isspace((int) ((unsigned char) *p)) != 0)) + p++; + + (void) strtol(p,&q,10); + if (p == q) + return; + + p=q; + count++; + + while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) + p++; + } + if (count == 0) + return; + i=0; + p=tags; + ignore=(TIFFFieldInfo *) AcquireQuantumMemory(count,sizeof(*ignore)); + // This also sets field_bit to 0 (FIELD_IGNORE) + ResetMagickMemory(ignore,0,count*sizeof(*ignore)); + while (*p != '\0') + { + while ((isspace((int) ((unsigned char) *p)) != 0)) + p++; + + ignore[i].field_tag=(ttag_t) strtol(p,&q,10); + + p=q; + i++; + + while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) + p++; + } + (void) TIFFMergeFieldInfo(tiff,ignore,(uint32) count); + ignore=(TIFFFieldInfo *) RelinquishMagickMemory(ignore); +} + static void TIFFTagExtender(TIFF *tiff) { static const TIFFFieldInfo @@ -1859,6 +1925,7 @@ static void TIFFTagExtender(TIFF *tiff) sizeof(*TIFFExtensions)); if (tag_extender != (TIFFExtendProc) NULL) (*tag_extender)(tiff); + TIFFIgnoreTags(tiff); } #endif