% Read/Write TIFF Image Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
# define TIFFTAG_COPYRIGHT 33432
# endif
# if !defined(TIFFTAG_OPIIMAGEID)
-# define TIFF_OPIIMAGEID 32781
+# define TIFFTAG_OPIIMAGEID 32781
# endif
\f
/*
{ EXIFTAG_SUBSECTIMEDIGITIZED, TIFF_ASCII, 0, "exif:SubSecTimeDigitized" },
{ EXIFTAG_FLASHPIXVERSION, TIFF_NOTYPE, 0, "exif:FlashpixVersion" },
{ EXIFTAG_PIXELXDIMENSION, TIFF_LONG, 0, "exif:PixelXDimension" },
- { EXIFTAG_PIXELXDIMENSION, TIFF_SHORT, 0, "exif:PixelXDimension" },
{ EXIFTAG_PIXELYDIMENSION, TIFF_LONG, 0, "exif:PixelYDimension" },
- { EXIFTAG_PIXELYDIMENSION, TIFF_SHORT, 0, "exif:PixelYDimension" },
{ EXIFTAG_RELATEDSOUNDFILE, TIFF_ASCII, 0, "exif:RelatedSoundFile" },
{ EXIFTAG_FLASHENERGY, TIFF_RATIONAL, 0, "exif:FlashEnergy" },
{ EXIFTAG_SPATIALFREQUENCYRESPONSE, TIFF_NOTYPE, 0, "exif:SpatialFrequencyResponse" },
return;
directory=TIFFCurrentDirectory(tiff);
if (TIFFReadEXIFDirectory(tiff,offset) == 0)
- return;
+ {
+ directory=TIFFCurrentDirectory(tiff);
+ return;
+ }
sans=NULL;
for (i=0; exif_info[i].tag != 0; i++)
{
}
case TIFF_SHORT:
{
- void
- *shorty;
-
if (exif_info[i].variable_length != 0)
{
- void
+ uint16
*shorty;
- if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans) != 0)
- (void) FormatLocaleString(value,MaxTextExtent,"%d",(int)
- (*(uint16 *) shorty));
- break;
+ if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%d",shorty[0]);
+ }
+ else
+ {
+ uint16
+ shorty;
+
+ shorty=0;
+ if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%d",shorty);
}
- if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) != 0)
- (void) FormatLocaleString(value,MaxTextExtent,"%d",(int)
- (*(uint16 *) &shorty));
break;
}
case TIFF_LONG:
{
- void
- *longy;
+ uint32
+ longy;
+ longy=0;
if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
- (void) FormatLocaleString(value,MaxTextExtent,"%d",
- (*(uint32 *) &longy));
+ (void) FormatLocaleString(value,MaxTextExtent,"%d",longy);
break;
}
#if defined(TIFF_VERSION_BIG)
case TIFF_LONG8:
{
- void
- *longy;
+ uint64
+ long8y;
- if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
+ long8y=0;
+ if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) != 0)
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
- ((MagickOffsetType) (*(uint64 *) &longy)));
+ ((MagickOffsetType) long8y));
break;
}
#endif
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
+ {
+ float
+ floaty;
+
+ floaty=0.0;
+ if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%g",(double) floaty);
+ break;
+ }
case TIFF_DOUBLE:
{
- void
- *rational;
+ double
+ doubley;
- if (TIFFGetField(tiff,exif_info[i].tag,&rational,&sans,&sans) != 0)
- (void) FormatLocaleString(value,MaxTextExtent,"%g",
- *((float *) &rational));
+ doubley=0.0;
+ if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%g",doubley);
break;
}
default:
}
do
{
+DisableMSCWarning(4127)
if (0 && (image_info->verbose != MagickFalse))
+RestoreMSCWarning
TIFFPrintDirectory(tiff,stdout,MagickFalse);
#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)
(void) SetImageProperty(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ?
SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)
TIFFGetA(*p)),q);
p--;
- q-=GetPixelChannels(image);;
+ q-=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;
- if (status == MagickTrue)
+ if (status != MagickFalse)
{
/*
Allocate next image structure.
if (status == MagickFalse)
break;
}
- } while (status == MagickTrue);
+ } while (status != MagickFalse);
(void) TIFFSetWarningHandler(warning_handler);
(void) TIFFSetErrorHandler(error_handler);
TIFFClose(tiff);
static TIFFExtendProc
tag_extender = (TIFFExtendProc) NULL;
+static void TIFFIgnoreTags(TIFF *tiff)
+{
+ char
+ *q;
+
+ const char
+ *p,
+ *tags;
+
+ Image
+ *image;
+
+ register ssize_t
+ i;
+
+ size_t
+ count;
+
+ TIFFFieldInfo
+ *ignore;
+
+ if (TIFFGetReadProc(tiff) != TIFFReadBlob)
+ return;
+ 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
sizeof(*TIFFExtensions));
if (tag_extender != (TIFFExtendProc) NULL)
(*tag_extender)(tiff);
+ TIFFIgnoreTags(tiff);
}
#endif
*entry;
if (tiff_semaphore == (SemaphoreInfo *) NULL)
- tiff_semaphore=AllocateSemaphoreInfo();
+ ActivateSemaphoreInfo(&tiff_semaphore);
LockSemaphoreInfo(tiff_semaphore);
if (instantiate_key == MagickFalse)
{
(void) UnregisterMagickInfo("TIF");
(void) UnregisterMagickInfo("PTIF");
if (tiff_semaphore == (SemaphoreInfo *) NULL)
- tiff_semaphore=AllocateSemaphoreInfo();
+ ActivateSemaphoreInfo(&tiff_semaphore);
LockSemaphoreInfo(tiff_semaphore);
if (instantiate_key != MagickFalse)
{
instantiate_key=MagickFalse;
}
UnlockSemaphoreInfo(tiff_semaphore);
- DestroySemaphoreInfo(&tiff_semaphore);
+ RelinquishSemaphoreInfo(&tiff_semaphore);
}
\f
#if defined(MAGICKCORE_TIFF_DELEGATE)
const char
*value;
- (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
- value=GetImageProperty(image,"tiff:hostcomputer",exception);
+ value=GetImageArtifact(image,"tiff:document");
+ if (value != (const char *) NULL)
+ (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,value);
+ value=GetImageArtifact(image,"tiff:hostcomputer");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_HOSTCOMPUTER,value);
- value=GetImageProperty(image,"tiff:artist",exception);
+ value=GetImageArtifact(image,"tiff:artist");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_ARTIST,value);
- value=GetImageProperty(image,"tiff:timestamp",exception);
+ value=GetImageArtifact(image,"tiff:timestamp");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_DATETIME,value);
- value=GetImageProperty(image,"tiff:make",exception);
+ value=GetImageArtifact(image,"tiff:make");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_MAKE,value);
- value=GetImageProperty(image,"tiff:model",exception);
+ value=GetImageArtifact(image,"tiff:model");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_MODEL,value);
- value=GetImageProperty(image,"tiff:software",exception);
+ value=GetImageArtifact(image,"tiff:software");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,value);
- value=GetImageProperty(image,"tiff:copyright",exception);
+ value=GetImageArtifact(image,"tiff:copyright");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_COPYRIGHT,value);
- value=GetImageProperty(image,"kodak-33423",exception);
+ value=GetImageArtifact(image,"kodak-33423");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,33423,value);
- value=GetImageProperty(image,"kodak-36867",exception);
+ value=GetImageArtifact(image,"kodak-36867");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,36867,value);
- value=GetImageProperty(image,"label",exception);
+ value=GetImageArtifact(image,"label");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_PAGENAME,value);
- value=GetImageProperty(image,"comment",exception);
+ value=GetImageArtifact(image,"comment");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_IMAGEDESCRIPTION,value);
}
case TIFF_SHORT:
{
uint16
- shorty;
+ field;
- shorty=(uint16) StringToLong(value);
- (void) TIFFSetField(tiff,exif_info[i].tag,shorty);
+ field=(uint16) StringToLong(value);
+ (void) TIFFSetField(tiff,exif_info[i].tag,field);
break;
}
case TIFF_LONG:
{
uint16
- ssize_ty;
+ field;
- ssize_ty=(uint16) StringToLong(value);
- (void) TIFFSetField(tiff,exif_info[i].tag,ssize_ty);
+ field=(uint16) StringToLong(value);
+ (void) TIFFSetField(tiff,exif_info[i].tag,field);
break;
}
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
{
float
- rational;
+ field;
- rational=StringToDouble(value,(char **) NULL);
- (void) TIFFSetField(tiff,exif_info[i].tag,rational);
+ field=StringToDouble(value,(char **) NULL);
+ (void) TIFFSetField(tiff,exif_info[i].tag,field);
break;
}
default:
if ((image_info->type != UndefinedType) &&
(image_info->type != OptimizeType))
(void) SetImageType(image,image_info->type,exception);
+ compression=UndefinedCompression;
+ if (image->compression != JPEGCompression)
+ compression=image->compression;
+ if (image_info->compression != UndefinedCompression)
+ compression=image_info->compression;
+ switch (compression)
+ {
+ case FaxCompression:
+ case Group4Compression:
+ {
+ (void) SetImageType(image,BilevelType,exception);
+ break;
+ }
+ case JPEGCompression:
+ {
+ (void) SetImageStorageClass(image,DirectClass,exception);
+ (void) SetImageDepth(image,8,exception);
+ break;
+ }
+ default:
+ break;
+ }
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
(void) TIFFSetField(tiff,TIFFTAG_IMAGELENGTH,(uint32) image->rows);
(void) TIFFSetField(tiff,TIFFTAG_IMAGEWIDTH,(uint32) image->columns);
- compression=image->compression;
- if (image_info->compression != UndefinedCompression)
- compression=image_info->compression;
switch (compression)
{
case FaxCompression:
}
}
#endif
- switch (compression)
- {
- case FaxCompression:
- case Group4Compression:
- {
- (void) SetImageType(image,BilevelType,exception);
- break;
- }
- case JPEGCompression:
- {
- (void) SetImageStorageClass(image,DirectClass,exception);
- (void) SetImageDepth(image,8,exception);
- break;
- }
- default:
- break;
- }
if (image->colorspace == CMYKColorspace)
{
photometric=PHOTOMETRIC_SEPARATED;
}
}
}
- if ((photometric == PHOTOMETRIC_RGB) &&
- (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse))
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
switch (image->endian)
{
case LSBEndian:
flags;
rows_per_strip+=(16-(rows_per_strip % 16));
- if (image->quality != 0)
- (void) TIFFSetField(tiff,TIFFTAG_JPEGQUALITY,image->quality);
if (image_info->quality != UndefinedCompressionQuality)
(void) TIFFSetField(tiff,TIFFTAG_JPEGQUALITY,image_info->quality);
(void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RAW);
if (rows_per_strip < 1)
rows_per_strip=1;
if ((image->rows/rows_per_strip) >= (1UL << 15))
- rows_per_strip=(image->rows >> 15);
+ rows_per_strip=(uint32) (image->rows >> 15);
(void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);
if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
{
(void) TIFFSetField(tiff,TIFFTAG_PAGENUMBER,page,pages);
}
(void) TIFFSetProperties(tiff,image,exception);
+DisableMSCWarning(4127)
if (0)
+RestoreMSCWarning
(void) TIFFSetEXIFProperties(tiff,image,exception);
/*
Write image scanlines.
if (image->colorspace == LabColorspace)
DecodeLabImage(image,exception);
DestroyTIFFInfo(&tiff_info);
- if (0 && (image_info->verbose == MagickTrue))
+DisableMSCWarning(4127)
+ if (0 && (image_info->verbose != MagickFalse))
+RestoreMSCWarning
TIFFPrintDirectory(tiff,stdout,MagickFalse);
(void) TIFFWriteDirectory(tiff);
image=SyncNextImageInList(image);