From 50d7105ee6b7218c59e43d448913516018eddb25 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Wed, 21 Dec 2005 14:24:41 +0000 Subject: [PATCH] Make RichTIFFIPTC, Photoshop and ICCProfile tags custom. --- libtiff/tif_dir.c | 36 +++--------------------------------- libtiff/tif_dir.h | 20 ++++---------------- libtiff/tif_print.c | 32 ++++++++++++++++++++------------ 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index f1034ab4..7cb25575 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -1,4 +1,4 @@ -/* $Id: tif_dir.c,v 1.61 2005-12-21 12:23:13 joris Exp $ */ +/* $Id: tif_dir.c,v 1.62 2005-12-21 14:24:41 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -394,22 +394,6 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) case TIFFTAG_NUMBEROFINKS: td->td_ninks = (uint16) va_arg(ap, int); break; - case TIFFTAG_ICCPROFILE: - td->td_profileLength = (uint32) va_arg(ap, uint32); - _TIFFsetByteArray(&td->td_profileData, va_arg(ap, void*), - td->td_profileLength); - break; - case TIFFTAG_PHOTOSHOP: - td->td_photoshopLength = (uint32) va_arg(ap, uint32); - _TIFFsetByteArray (&td->td_photoshopData, va_arg(ap, void*), - td->td_photoshopLength); - break; - case TIFFTAG_RICHTIFFIPTC: - td->td_richtiffiptcLength = (uint32) va_arg(ap, uint32); - _TIFFsetLongArray ((uint32**)&td->td_richtiffiptcData, - va_arg(ap, uint32*), - td->td_richtiffiptcLength); - break; default: { const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); TIFFTagValue *tv; @@ -838,18 +822,6 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) case TIFFTAG_NUMBEROFINKS: *va_arg(ap, uint16*) = td->td_ninks; break; - case TIFFTAG_ICCPROFILE: - *va_arg(ap, uint32*) = td->td_profileLength; - *va_arg(ap, void**) = td->td_profileData; - break; - case TIFFTAG_PHOTOSHOP: - *va_arg(ap, uint32*) = td->td_photoshopLength; - *va_arg(ap, void**) = td->td_photoshopData; - break; - case TIFFTAG_RICHTIFFIPTC: - *va_arg(ap, uint32*) = td->td_richtiffiptcLength; - *va_arg(ap, void**) = td->td_richtiffiptcData; - break; default: { @@ -1015,9 +987,6 @@ TIFFFreeDirectory(TIFF* tif) CleanupField(td_transferfunction[0]); CleanupField(td_transferfunction[1]); CleanupField(td_transferfunction[2]); - CleanupField(td_profileData); - CleanupField(td_photoshopData); - CleanupField(td_richtiffiptcData); CleanupField(td_stripoffset); CleanupField(td_stripbytecount); @@ -1275,7 +1244,8 @@ TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) tdir_t n; if (tif->tif_mode == O_RDONLY) { - TIFFErrorExit(tif->tif_clientdata, module, "Can not unlink directory in read-only file"); + TIFFErrorExit(tif->tif_clientdata, module, + "Can not unlink directory in read-only file"); return (0); } /* diff --git a/libtiff/tif_dir.h b/libtiff/tif_dir.h index e35cc6f9..6ac2ca4c 100644 --- a/libtiff/tif_dir.h +++ b/libtiff/tif_dir.h @@ -1,4 +1,4 @@ -/* $Id: tif_dir.h,v 1.23 2005-12-12 16:13:18 dron Exp $ */ +/* $Id: tif_dir.h,v 1.24 2005-12-21 14:24:41 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -81,15 +81,6 @@ typedef struct { uint16 td_dotrange[2]; int td_inknameslen; char* td_inknames; - /* ICC parameters */ - uint32 td_profileLength; - void *td_profileData; - /* Adobe Photoshop tag handling */ - uint32 td_photoshopLength; - void *td_photoshopData; - /* IPTC parameters */ - uint32 td_richtiffiptcLength; - void *td_richtiffiptcData; int td_customValueCount; TIFFTagValue *td_customValues; } TIFFDirectory; @@ -163,9 +154,6 @@ typedef struct { /* unused - was FIELD_TARGETPRINTER 48 */ #define FIELD_SUBIFD 49 #define FIELD_NUMBEROFINKS 50 -#define FIELD_ICCPROFILE 51 -#define FIELD_PHOTOSHOP 52 -#define FIELD_RICHTIFFIPTC 53 #define FIELD_STONITS 54 /* FIELD_CUSTOM (see tiffio.h) 65 */ /* end of support for well-known tags; codec-private tags follow */ @@ -408,13 +396,13 @@ static const TIFFFieldInfo tiffFieldInfo[] = { { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, FIELD_CUSTOM, 1, 0, "Copyright" }, /* end Pixar tags */ - { TIFFTAG_RICHTIFFIPTC, -1, -3, TIFF_LONG, FIELD_RICHTIFFIPTC, + { TIFFTAG_RICHTIFFIPTC, -1, -3, TIFF_LONG, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC" }, - { TIFFTAG_PHOTOSHOP, -1, -3, TIFF_BYTE, FIELD_PHOTOSHOP, + { TIFFTAG_PHOTOSHOP, -1, -3, TIFF_BYTE, FIELD_CUSTOM, 0, 1, "Photoshop" }, { TIFFTAG_EXIFIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset" }, - { TIFFTAG_ICCPROFILE, -1, -3, TIFF_UNDEFINED, FIELD_ICCPROFILE, + { TIFFTAG_ICCPROFILE, -1, -3, TIFF_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile" }, { TIFFTAG_GPSIFD, 1, 1, TIFF_LONG, FIELD_CUSTOM, 0, 0, "GPSIFDOffset" }, diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index 22742c59..611fd5c2 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.30 2005-12-09 17:52:40 dron Exp $ */ +/* $Id: tif_print.c,v 1.31 2005-12-21 14:24:41 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -128,8 +128,8 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, fprintf(fd, " %2d: %5g %5g\n", i, ((float *)raw_data)[2*i+0], ((float *)raw_data)[2*i+1]); + return 1; } - return 1; case TIFFTAG_XMLPACKET: { uint32 i; @@ -138,8 +138,25 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, for(i = 0; i < value_count; i++) fputc(((char *)raw_data)[i], fd); fprintf( fd, "\n" ); + return 1; } - return 1; + case TIFFTAG_RICHTIFFIPTC: + /* + * XXX: for some weird reason RichTIFFIPTC tag + * defined as array of LONG values. + */ + fprintf(fd, + " RichTIFFIPTC Data: , %lu bytes\n", + (unsigned long) value_count * 4); + return 1; + case TIFFTAG_PHOTOSHOP: + fprintf(fd, " Photoshop Data: , %lu bytes\n", + (unsigned long) value_count); + return 1; + case TIFFTAG_ICCPROFILE: + fprintf(fd, " ICC Profile: , %lu bytes\n", + (unsigned long) value_count); + return 1; } return 0; @@ -473,15 +490,6 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } else fprintf(fd, "(present)\n"); } - if (TIFFFieldSet(tif,FIELD_ICCPROFILE)) - fprintf(fd, " ICC Profile: , %lu bytes\n", - (unsigned long) td->td_profileLength); - if (TIFFFieldSet(tif,FIELD_PHOTOSHOP)) - fprintf(fd, " Photoshop Data: , %lu bytes\n", - (unsigned long) td->td_photoshopLength); - if (TIFFFieldSet(tif,FIELD_RICHTIFFIPTC)) - fprintf(fd, " RichTIFFIPTC Data: , %lu bytes\n", - (unsigned long) td->td_richtiffiptcLength); if (TIFFFieldSet(tif, FIELD_SUBIFD)) { fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++)