% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 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 %
/*
Include declarations.
*/
-#include "magick/studio.h"
-#include "magick/attribute.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/color.h"
-#include "magick/color-private.h"
-#include "magick/colormap.h"
-#include "magick/colorspace.h"
-#include "magick/constitute.h"
-#include "magick/enhance.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/geometry.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/log.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/module.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/option.h"
-#include "magick/property.h"
-#include "magick/quantum.h"
-#include "magick/quantum-private.h"
-#include "magick/profile.h"
-#include "magick/resize.h"
-#include "magick/resource_.h"
-#include "magick/semaphore.h"
-#include "magick/splay-tree.h"
-#include "magick/static.h"
-#include "magick/statistic.h"
-#include "magick/string_.h"
-#include "magick/string-private.h"
-#include "magick/thread_.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/artifact.h"
+#include "MagickCore/attribute.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/enhance.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/geometry.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/log.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/option.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/pixel-private.h"
+#include "MagickCore/property.h"
+#include "MagickCore/quantum.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/profile.h"
+#include "MagickCore/resize.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/semaphore.h"
+#include "MagickCore/splay-tree.h"
+#include "MagickCore/static.h"
+#include "MagickCore/statistic.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
+#include "MagickCore/thread_.h"
+#include "MagickCore/token.h"
+#include "MagickCore/utility.h"
#if defined(MAGICKCORE_TIFF_DELEGATE)
# if defined(MAGICKCORE_HAVE_TIFFCONF_H)
# include "tiffconf.h"
# if !defined(PREDICTOR_HORIZONTAL)
# define PREDICTOR_HORIZONTAL 2
# endif
+# if !defined(TIFFTAG_COPYRIGHT)
+# define TIFFTAG_COPYRIGHT 33432
+# endif
+# if !defined(TIFFTAG_OPIIMAGEID)
+# define TIFF_OPIIMAGEID 32781
+# endif
\f
/*
Typedef declarations.
{ EXIFTAG_EXPOSUREPROGRAM, TIFF_SHORT, "exif:ExposureProgram" },
{ EXIFTAG_SPECTRALSENSITIVITY, TIFF_ASCII, "exif:SpectralSensitivity" },
{ EXIFTAG_ISOSPEEDRATINGS, TIFF_SHORT, "exif:ISOSpeedRatings" },
- { EXIFTAG_OECF, TIFF_UNDEFINED, "exif:OptoelectricConversionFactor" },
- { EXIFTAG_EXIFVERSION, TIFF_UNDEFINED, "exif:ExifVersion" },
+ { EXIFTAG_OECF, TIFF_NOTYPE, "exif:OptoelectricConversionFactor" },
+ { EXIFTAG_EXIFVERSION, TIFF_NOTYPE, "exif:ExifVersion" },
{ EXIFTAG_DATETIMEORIGINAL, TIFF_ASCII, "exif:DateTimeOriginal" },
{ EXIFTAG_DATETIMEDIGITIZED, TIFF_ASCII, "exif:DateTimeDigitized" },
- { EXIFTAG_COMPONENTSCONFIGURATION, TIFF_UNDEFINED, "exif:ComponentsConfiguration" },
+ { EXIFTAG_COMPONENTSCONFIGURATION, TIFF_NOTYPE, "exif:ComponentsConfiguration" },
{ EXIFTAG_COMPRESSEDBITSPERPIXEL, TIFF_RATIONAL, "exif:CompressedBitsPerPixel" },
{ EXIFTAG_SHUTTERSPEEDVALUE, TIFF_SRATIONAL, "exif:ShutterSpeedValue" },
{ EXIFTAG_APERTUREVALUE, TIFF_RATIONAL, "exif:ApertureValue" },
{ EXIFTAG_LIGHTSOURCE, TIFF_SHORT, "exif:LightSource" },
{ EXIFTAG_FLASH, TIFF_SHORT, "exif:Flash" },
{ EXIFTAG_FOCALLENGTH, TIFF_RATIONAL, "exif:FocalLength" },
- /* { EXIFTAG_SUBJECTAREA, TIFF_SHORT, "exif:SubjectArea" }, */
- { EXIFTAG_MAKERNOTE, TIFF_UNDEFINED, "exif:MakerNote" },
- { EXIFTAG_USERCOMMENT, TIFF_UNDEFINED, "exif:UserComment" },
+ { EXIFTAG_SUBJECTAREA, TIFF_NOTYPE, "exif:SubjectArea" },
+ { EXIFTAG_MAKERNOTE, TIFF_NOTYPE, "exif:MakerNote" },
+ { EXIFTAG_USERCOMMENT, TIFF_NOTYPE, "exif:UserComment" },
{ EXIFTAG_SUBSECTIME, TIFF_ASCII, "exif:SubSecTime" },
{ EXIFTAG_SUBSECTIMEORIGINAL, TIFF_ASCII, "exif:SubSecTimeOriginal" },
{ EXIFTAG_SUBSECTIMEDIGITIZED, TIFF_ASCII, "exif:SubSecTimeDigitized" },
- { EXIFTAG_FLASHPIXVERSION, TIFF_UNDEFINED, "exif:FlashpixVersion" },
+ { EXIFTAG_FLASHPIXVERSION, TIFF_NOTYPE, "exif:FlashpixVersion" },
{ EXIFTAG_PIXELXDIMENSION, TIFF_LONG, "exif:PixelXDimension" },
{ EXIFTAG_PIXELXDIMENSION, TIFF_SHORT, "exif:PixelXDimension" },
{ EXIFTAG_PIXELYDIMENSION, TIFF_LONG, "exif:PixelYDimension" },
{ EXIFTAG_PIXELYDIMENSION, TIFF_SHORT, "exif:PixelYDimension" },
{ EXIFTAG_RELATEDSOUNDFILE, TIFF_ASCII, "exif:RelatedSoundFile" },
{ EXIFTAG_FLASHENERGY, TIFF_RATIONAL, "exif:FlashEnergy" },
- { EXIFTAG_SPATIALFREQUENCYRESPONSE, TIFF_UNDEFINED, "exif:SpatialFrequencyResponse" },
+ { EXIFTAG_SPATIALFREQUENCYRESPONSE, TIFF_NOTYPE, "exif:SpatialFrequencyResponse" },
{ EXIFTAG_FOCALPLANEXRESOLUTION, TIFF_RATIONAL, "exif:FocalPlaneXResolution" },
{ EXIFTAG_FOCALPLANEYRESOLUTION, TIFF_RATIONAL, "exif:FocalPlaneYResolution" },
{ EXIFTAG_FOCALPLANERESOLUTIONUNIT, TIFF_SHORT, "exif:FocalPlaneResolutionUnit" },
{ EXIFTAG_SUBJECTLOCATION, TIFF_SHORT, "exif:SubjectLocation" },
{ EXIFTAG_EXPOSUREINDEX, TIFF_RATIONAL, "exif:ExposureIndex" },
{ EXIFTAG_SENSINGMETHOD, TIFF_SHORT, "exif:SensingMethod" },
- { EXIFTAG_FILESOURCE, TIFF_UNDEFINED, "exif:FileSource" },
- { EXIFTAG_SCENETYPE, TIFF_UNDEFINED, "exif:SceneType" },
- { EXIFTAG_CFAPATTERN, TIFF_UNDEFINED, "exif:CFAPattern" },
+ { EXIFTAG_FILESOURCE, TIFF_NOTYPE, "exif:FileSource" },
+ { EXIFTAG_SCENETYPE, TIFF_NOTYPE, "exif:SceneType" },
+ { EXIFTAG_CFAPATTERN, TIFF_NOTYPE, "exif:CFAPattern" },
{ EXIFTAG_CUSTOMRENDERED, TIFF_SHORT, "exif:CustomRendered" },
{ EXIFTAG_EXPOSUREMODE, TIFF_SHORT, "exif:ExposureMode" },
{ EXIFTAG_WHITEBALANCE, TIFF_SHORT, "exif:WhiteBalance" },
{ EXIFTAG_CONTRAST, TIFF_SHORT, "exif:Contrast" },
{ EXIFTAG_SATURATION, TIFF_SHORT, "exif:Saturation" },
{ EXIFTAG_SHARPNESS, TIFF_SHORT, "exif:Sharpness" },
- { EXIFTAG_DEVICESETTINGDESCRIPTION, TIFF_UNDEFINED, "exif:DeviceSettingDescription" },
+ { EXIFTAG_DEVICESETTINGDESCRIPTION, TIFF_NOTYPE, "exif:DeviceSettingDescription" },
{ EXIFTAG_SUBJECTDISTANCERANGE, TIFF_SHORT, "exif:SubjectDistanceRange" },
{ EXIFTAG_IMAGEUNIQUEID, TIFF_ASCII, "exif:ImageUniqueID" },
{ 0, 0, (char *) NULL }
ReadTIFFImage(const ImageInfo *,ExceptionInfo *);
static MagickBooleanType
- WriteGROUP4Image(const ImageInfo *,Image *),
- WritePTIFImage(const ImageInfo *,Image *),
- WriteTIFFImage(const ImageInfo *,Image *);
+ WriteGROUP4Image(const ImageInfo *,Image *,ExceptionInfo *),
+ WritePTIFImage(const ImageInfo *,Image *,ExceptionInfo *),
+ WriteTIFFImage(const ImageInfo *,Image *,ExceptionInfo *);
#endif
\f
/*
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
length=WriteLSBLong(file,(size_t) (strip_offset-8));
length=fwrite("\050\001\003\000\001\000\000\000\002\000\000\000",1,12,file);
length=fwrite("\000\000\000\000",1,4,file);
- length=WriteLSBLong(file,image->x_resolution);
+ length=WriteLSBLong(file,(long) image->resolution.x);
length=WriteLSBLong(file,1);
for (length=0; (c=ReadBlobByte(image)) != EOF; length++)
(void) fputc(c,file);
Read TIFF image.
*/
read_info=CloneImageInfo((ImageInfo *) NULL);
- (void) FormatMagickString(read_info->filename,MaxTextExtent,"%s",filename);
+ (void) FormatLocaleString(read_info->filename,MaxTextExtent,"%s",filename);
image=ReadTIFFImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (image != (Image *) NULL)
%
*/
+static MagickBooleanType DecodeLabImage(Image *image,ExceptionInfo *exception)
+{
+ CacheView
+ *image_view;
+
+ MagickBooleanType
+ status;
+
+ ssize_t
+ y;
+
+ status=MagickTrue;
+ image_view=AcquireAuthenticCacheView(image,exception);
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (status == MagickFalse)
+ continue;
+ q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ if (q == (Quantum *) NULL)
+ {
+ status=MagickFalse;
+ continue;
+ }
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ double
+ a,
+ b;
+
+ a=QuantumScale*GetPixela(image,q)+0.5;
+ if (a > 1.0)
+ a-=1.0;
+ b=QuantumScale*GetPixelb(image,q)+0.5;
+ if (b > 1.0)
+ b-=1.0;
+ SetPixela(image,QuantumRange*a,q);
+ SetPixelb(image,QuantumRange*b,q);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ status=MagickFalse;
+ }
+ image_view=DestroyCacheView(image_view);
+ return(status);
+}
+
static inline size_t MagickMax(const size_t x,const size_t y)
{
if (x > y)
}
static MagickBooleanType ReadProfile(Image *image,const char *name,
- unsigned char *datum,ssize_t length)
+ unsigned char *datum,ssize_t length,ExceptionInfo *exception)
{
MagickBooleanType
status;
if (length < 4)
return(MagickFalse);
}
- profile=AcquireStringInfo((size_t) length);
- SetStringInfoDatum(profile,datum+i);
- status=SetImageProfile(image,name,profile);
+ profile=BlobToStringInfo(datum+i,(size_t) length);
+ if (profile == (StringInfo *) NULL)
+ ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+ image->filename);
+ status=SetImageProfile(image,name,profile,exception);
profile=DestroyStringInfo(profile);
if (status == MagickFalse)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
"`%s'",module);
}
-static void TIFFGetProfiles(TIFF *tiff,Image *image)
+static toff_t TIFFGetBlobSize(thandle_t image)
+{
+ return((toff_t) GetBlobSize((Image *) image));
+}
+
+static void TIFFGetProfiles(TIFF *tiff,Image *image,ExceptionInfo *exception)
{
uint32
length;
#if defined(TIFFTAG_ICCPROFILE)
length=0;
if (TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1)
- (void) ReadProfile(image,"icc",profile,(ssize_t) length);
+ (void) ReadProfile(image,"icc",profile,(ssize_t) length,exception);
#endif
#if defined(TIFFTAG_PHOTOSHOP)
length=0;
if (TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1)
- (void) ReadProfile(image,"8bim",profile,(ssize_t) length);
+ (void) ReadProfile(image,"8bim",profile,(ssize_t) length,exception);
#endif
#if defined(TIFFTAG_RICHTIFFIPTC)
length=0;
{
if (TIFFIsByteSwapped(tiff) != 0)
TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length);
- (void) ReadProfile(image,"iptc",profile,4L*length);
+ (void) ReadProfile(image,"iptc",profile,4L*length,exception);
}
#endif
#if defined(TIFFTAG_XMLPACKET)
length=0;
if (TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1)
- (void) ReadProfile(image,"xmp",profile,(ssize_t) length);
+ (void) ReadProfile(image,"xmp",profile,(ssize_t) length,exception);
#endif
length=0;
if (TIFFGetField(tiff,37724,&length,&profile) == 1)
- (void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length);
+ (void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length,exception);
+ if (TIFFGetField(tiff,34118,&length,&profile) == 1)
+ (void) ReadProfile(image,"tiff:34118",profile,(ssize_t) length,exception);
}
-static void TIFFGetProperties(TIFF *tiff,Image *image)
+static void TIFFGetProperties(TIFF *tiff,Image *image,ExceptionInfo *exception)
{
char
+ message[MaxTextExtent],
*text;
+ uint32
+ count;
+
if (TIFFGetField(tiff,TIFFTAG_ARTIST,&text) == 1)
- (void) SetImageProperty(image,"tiff:artist",text);
+ (void) SetImageProperty(image,"tiff:artist",text,exception);
+ if (TIFFGetField(tiff,TIFFTAG_COPYRIGHT,&text) == 1)
+ (void) SetImageProperty(image,"tiff:copyright",text,exception);
if (TIFFGetField(tiff,TIFFTAG_DATETIME,&text) == 1)
- (void) SetImageProperty(image,"tiff:timestamp",text);
- if (TIFFGetField(tiff,TIFFTAG_SOFTWARE,&text) == 1)
- (void) SetImageProperty(image,"tiff:software",text);
- if (TIFFGetField(tiff,TIFFTAG_HOSTCOMPUTER,&text) == 1)
- (void) SetImageProperty(image,"tiff:hostcomputer",text);
+ (void) SetImageProperty(image,"tiff:timestamp",text,exception);
if (TIFFGetField(tiff,TIFFTAG_DOCUMENTNAME,&text) == 1)
- (void) SetImageProperty(image,"tiff:document",text);
+ (void) SetImageProperty(image,"tiff:document",text,exception);
+ if (TIFFGetField(tiff,TIFFTAG_HOSTCOMPUTER,&text) == 1)
+ (void) SetImageProperty(image,"tiff:hostcomputer",text,exception);
+ if (TIFFGetField(tiff,TIFFTAG_IMAGEDESCRIPTION,&text) == 1)
+ (void) SetImageProperty(image,"comment",text,exception);
if (TIFFGetField(tiff,TIFFTAG_MAKE,&text) == 1)
- (void) SetImageProperty(image,"tiff:make",text);
+ (void) SetImageProperty(image,"tiff:make",text,exception);
if (TIFFGetField(tiff,TIFFTAG_MODEL,&text) == 1)
- (void) SetImageProperty(image,"tiff:model",text);
- if (TIFFGetField(tiff,33432,&text) == 1)
- (void) SetImageProperty(image,"tiff:copyright",text);
+ (void) SetImageProperty(image,"tiff:model",text,exception);
+ if (TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1)
+ {
+ if (count >= MaxTextExtent)
+ count=MaxTextExtent-1;
+ (void) CopyMagickString(message,text,count+1);
+ (void) SetImageProperty(image,"tiff:image-id",message,exception);
+ }
if (TIFFGetField(tiff,TIFFTAG_PAGENAME,&text) == 1)
- (void) SetImageProperty(image,"label",text);
- if (TIFFGetField(tiff,TIFFTAG_IMAGEDESCRIPTION,&text) == 1)
- (void) SetImageProperty(image,"comment",text);
+ (void) SetImageProperty(image,"label",text,exception);
+ if (TIFFGetField(tiff,TIFFTAG_SOFTWARE,&text) == 1)
+ (void) SetImageProperty(image,"tiff:software",text,exception);
+ if (TIFFGetField(tiff,33423,&count,&text) == 1)
+ {
+ if (count >= MaxTextExtent)
+ count=MaxTextExtent-1;
+ (void) CopyMagickString(message,text,count+1);
+ (void) SetImageProperty(image,"tiff:kodak-33423",message,exception);
+ }
+ if (TIFFGetField(tiff,36867,&count,&text) == 1)
+ {
+ if (count >= MaxTextExtent)
+ count=MaxTextExtent-1;
+ (void) CopyMagickString(message,text,count+1);
+ (void) SetImageProperty(image,"tiff:kodak-36867",message,exception);
+ }
}
-static void TIFFGetEXIFProperties(TIFF *tiff,Image *image)
+static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
+ ExceptionInfo *exception)
{
#if defined(MAGICKCORE_HAVE_TIFFREADEXIFDIRECTORY)
char
tdir_t
directory;
+#if defined(TIFF_VERSION_BIG)
+ uint64
+#else
uint32
+#endif
offset;
+ void
+ *sans;
+
/*
Read EXIF properties.
*/
+ offset=0;
if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) == 0)
return;
directory=TIFFCurrentDirectory(tiff);
if (TIFFReadEXIFDirectory(tiff,offset) == 0)
return;
+ sans=NULL;
for (i=0; exif_info[i].tag != 0; i++)
{
*value='\0';
char
*ascii;
- if (TIFFGetField(tiff,exif_info[i].tag,&ascii) != 0)
- (void) CopyMagickMemory(value,ascii,MaxTextExtent);
+ ascii=(char *) NULL;
+ if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) != 0) &&
+ (ascii != (char *) NULL) && (*ascii != '\0'))
+ (void) CopyMagickString(value,ascii,MaxTextExtent);
break;
}
case TIFF_SHORT:
{
uint16
- shorty;
+ shorty[2] = { 0, 0};
- if (TIFFGetField(tiff,exif_info[i].tag,&shorty) != 0)
- (void) FormatMagickString(value,MaxTextExtent,"%d",shorty);
+ if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%d",(int) shorty[0]);
break;
}
case TIFF_LONG:
{
uint32
- ssize_ty;
+ longy;
- if (TIFFGetField(tiff,exif_info[i].tag,&ssize_ty) != 0)
- (void) FormatMagickString(value,MaxTextExtent,"%d",ssize_ty);
+ if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%d",longy);
break;
}
+#if defined(TIFF_VERSION_BIG)
+ case TIFF_LONG8:
+ {
+ uint64
+ longy;
+
+ if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
+ ((MagickOffsetType) longy));
+ break;
+ }
+#endif
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
+ case TIFF_FLOAT:
+ case TIFF_DOUBLE:
{
float
- rational;
+ rational[16];
- if (TIFFGetField(tiff,exif_info[i].tag,&rational) != 0)
- (void) FormatMagickString(value,MaxTextExtent,"%g",rational);
+ if (TIFFGetField(tiff,exif_info[i].tag,&rational,&sans,&sans) != 0)
+ (void) FormatLocaleString(value,MaxTextExtent,"%g",rational[0]);
break;
}
default:
break;
}
if (*value != '\0')
- (void) SetImageProperty(image,exif_info[i].property,value);
+ (void) SetImageProperty(image,exif_info[i].property,value,exception);
}
TIFFSetDirectory(tiff,directory);
#else
return((toff_t) SeekBlob((Image *) image,(MagickOffsetType) offset,whence));
}
-static toff_t TIFFGetBlobSize(thandle_t image)
-{
- return((toff_t) GetBlobSize((Image *) image));
-}
-
static void TIFFUnmapBlob(thandle_t image,tdata_t base,toff_t size)
{
(void) image;
Image
*image;
- ssize_t
- y;
-
MagickBooleanType
associated_alpha,
debug,
length,
pad;
+ ssize_t
+ y;
+
TIFF
*tiff;
unsigned char
*pixels;
- size_t
- lsb_first;
-
/*
Open image.
*/
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
for (i=0; i < (ssize_t) image_info->scene; i++)
{
(void) TIFFReadDirectory(tiff);
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
{
if (0 && (image_info->verbose != MagickFalse))
TIFFPrintDirectory(tiff,stdout,MagickFalse);
+#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)
(void) SetImageProperty(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ?
- "lsb" : "msb");
+ "lsb" : "msb",exception);
+#endif
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_IMAGEWIDTH,&width);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format);
if (sample_format == SAMPLEFORMAT_IEEEFP)
- (void) SetImageProperty(image,"quantum:format","floating-point");
+ (void) SetImageProperty(image,"quantum:format","floating-point",
+ exception);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric);
{
case PHOTOMETRIC_MINISBLACK:
{
- (void) SetImageProperty(image,"tiff:photometric","min-is-black");
+ (void) SetImageProperty(image,"tiff:photometric","min-is-black",
+ exception);
break;
}
case PHOTOMETRIC_MINISWHITE:
{
- (void) SetImageProperty(image,"tiff:photometric","min-is-white");
+ (void) SetImageProperty(image,"tiff:photometric","min-is-white",
+ exception);
break;
}
case PHOTOMETRIC_PALETTE:
{
- (void) SetImageProperty(image,"tiff:photometric","palette");
+ (void) SetImageProperty(image,"tiff:photometric","palette",exception);
break;
}
case PHOTOMETRIC_RGB:
{
- (void) SetImageProperty(image,"tiff:photometric","RGB");
+ (void) SetImageProperty(image,"tiff:photometric","RGB",exception);
break;
}
case PHOTOMETRIC_CIELAB:
{
- (void) SetImageProperty(image,"tiff:photometric","CIELAB");
+ (void) SetImageProperty(image,"tiff:photometric","CIELAB",exception);
break;
}
case PHOTOMETRIC_SEPARATED:
{
- (void) SetImageProperty(image,"tiff:photometric","separated");
+ (void) SetImageProperty(image,"tiff:photometric","separated",exception);
break;
}
case PHOTOMETRIC_YCBCR:
{
- (void) SetImageProperty(image,"tiff:photometric","YCBCR");
+ (void) SetImageProperty(image,"tiff:photometric","YCBCR",exception);
break;
}
default:
{
- (void) SetImageProperty(image,"tiff:photometric","unknown");
+ (void) SetImageProperty(image,"tiff:photometric","unknown",exception);
break;
}
}
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"Max sample value: %u",max_sample_value);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"Photometric "
- "interpretation: %s",GetImageProperty(image,"tiff:photometric"));
+ "interpretation: %s",GetImageProperty(image,"tiff:photometric",
+ exception));
}
image->columns=(size_t) width;
image->rows=(size_t) height;
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image depth: %.20g",
(double) image->depth);
- lsb_first=1;
image->endian=MSBEndian;
- if ((int) (*(char *) &lsb_first) != 0)
+ if (endian == FILLORDER_LSB2MSB)
image->endian=LSBEndian;
+ if ((photometric == PHOTOMETRIC_MINISBLACK) ||
+ (photometric == PHOTOMETRIC_MINISWHITE))
+ SetImageColorspace(image,GRAYColorspace,exception);
if (photometric == PHOTOMETRIC_SEPARATED)
- image->colorspace=CMYKColorspace;
+ SetImageColorspace(image,CMYKColorspace,exception);
if (photometric == PHOTOMETRIC_CIELAB)
- image->colorspace=LabColorspace;
+ SetImageColorspace(image,LabColorspace,exception);
+ TIFFGetProfiles(tiff,image,exception);
+ TIFFGetProperties(tiff,image,exception);
+ option=GetImageOption(image_info,"tiff:exif-properties");
+ if (IfMagickTrue(IsStringNotFalse(option))) /* enabled by default */
+ TIFFGetEXIFProperties(tiff,image,exception);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,
&samples_per_pixel);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units);
- x_resolution=(float) image->x_resolution;
- y_resolution=(float) image->y_resolution;
+ x_resolution=(float) image->resolution.x;
+ y_resolution=(float) image->resolution.y;
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution);
- image->x_resolution=x_resolution;
- image->y_resolution=y_resolution;
- x_position=(float) image->page.x/x_resolution;
- y_position=(float) image->page.y/y_resolution;
+ image->resolution.x=x_resolution;
+ image->resolution.y=y_resolution;
+ x_position=(float) PerceptibleReciprocal(x_resolution)*image->page.x;
+ y_position=(float) PerceptibleReciprocal(y_resolution)*image->page.y;
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
image->chromaticity.blue_primary.x=chromaticity[4];
image->chromaticity.blue_primary.y=chromaticity[5];
}
- TIFFGetProperties(tiff,image);
- option=GetImageOption(image_info,"tiff:exif");
- if ((option != (const char *) NULL) &&
- (IsMagickTrue(option) != MagickFalse))
- TIFFGetEXIFProperties(tiff,image);
- TIFFGetProfiles(tiff,image);
- /*
- Allocate memory for the image and pixel buffer.
- */
#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)
if ((compress_tag != COMPRESSION_NONE) &&
(TIFFIsCODECConfigured(compress_tag) == 0))
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING,
&horizontal,&vertical);
- (void) FormatMagickString(sampling_factor,MaxTextExtent,"%dx%d",
+ (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d",
horizontal,vertical);
(void) SetImageProperty(image,"jpeg:sampling-factor",
- sampling_factor);
+ sampling_factor,exception);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"Sampling Factors: %s",sampling_factor);
- if ((samples_per_pixel > 1) && (photometric == PHOTOMETRIC_YCBCR))
- {
- (void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,
- JPEGCOLORMODE_RGB);
- photometric=PHOTOMETRIC_RGB;
- }
}
#endif
break;
case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;
default: image->compression=RLECompression; break;
}
+ /*
+ Allocate memory for the image and pixel buffer.
+ */
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
{
status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);
if (status == MagickFalse)
{
+ quantum_info=DestroyQuantumInfo(quantum_info);
TIFFClose(tiff);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
if (extra_samples == 0)
{
if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))
- image->matte=MagickTrue;
+ image->alpha_trait=BlendPixelTrait;
}
else
for (i=0; i < extra_samples; i++)
{
- image->matte=MagickTrue;
+ image->alpha_trait=BlendPixelTrait;
if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
}
if (option != (const char *) NULL)
associated_alpha=LocaleCompare(option,"associated") == 0 ? MagickTrue :
MagickFalse;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
(void) SetImageProperty(image,"tiff:alpha",
- associated_alpha != MagickFalse ? "associated" : "unassociated");
+ associated_alpha != MagickFalse ? "associated" : "unassociated",
+ exception);
if ((photometric == PHOTOMETRIC_PALETTE) &&
(pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))
{
colors;
colors=(size_t) GetQuantumRange(bits_per_sample)+1;
- if (AcquireImageColormap(image,colors) == MagickFalse)
+ if (AcquireImageColormap(image,colors,exception) == MagickFalse)
{
TIFFClose(tiff);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
value[MaxTextExtent];
method=ReadStripMethod;
- (void) FormatMagickString(value,MaxTextExtent,"%u",
+ (void) FormatLocaleString(value,MaxTextExtent,"%u",
(unsigned int) rows_per_strip);
- (void) SetImageProperty(image,"tiff:rows-per-strip",value);
+ (void) SetImageProperty(image,"tiff:rows-per-strip",value,exception);
}
if ((samples_per_pixel >= 2) && (interlace == PLANARCONFIG_CONTIG))
method=ReadRGBAMethod;
if ((photometric != PHOTOMETRIC_SEPARATED) &&
(interlace == PLANARCONFIG_SEPARATE) && (bits_per_sample < 64))
method=ReadGenericMethod;
- if (image->compression == JPEGCompression)
- method=ReadGenericMethod;
if (TIFFIsTiled(tiff) != MagickFalse)
method=ReadTileMethod;
+ quantum_info->endian=LSBEndian;
quantum_type=RGBQuantum;
pixels=GetQuantumPixels(quantum_info);
switch (method)
/*
Initialize colormap.
*/
+ red_colormap=(uint16 *) NULL;
+ green_colormap=(uint16 *) NULL;
+ blue_colormap=(uint16 *) NULL;
(void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
&green_colormap,&blue_colormap);
- range=255; /* might be old style 8-bit colormap */
- for (i=0; i < (ssize_t) image->colors; i++)
- if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
- (blue_colormap[i] >= 256))
+ if ((red_colormap != (uint16 *) NULL) &&
+ (green_colormap != (uint16 *) NULL) &&
+ (blue_colormap != (uint16 *) NULL))
+ {
+ range=255; /* might be old style 8-bit colormap */
+ for (i=0; i < (ssize_t) image->colors; i++)
+ if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
+ (blue_colormap[i] >= 256))
+ {
+ range=65535;
+ break;
+ }
+ for (i=0; i < (ssize_t) image->colors; i++)
{
- range=65535;
- break;
+ image->colormap[i].red=ClampToQuantum(((double)
+ QuantumRange*red_colormap[i])/range);
+ image->colormap[i].green=ClampToQuantum(((double)
+ QuantumRange*green_colormap[i])/range);
+ image->colormap[i].blue=ClampToQuantum(((double)
+ QuantumRange*blue_colormap[i])/range);
}
- for (i=0; i < (ssize_t) image->colors; i++)
- {
- image->colormap[i].red=ClampToQuantum(((double) QuantumRange*
- red_colormap[i])/range);
- image->colormap[i].green=ClampToQuantum(((double) QuantumRange*
- green_colormap[i])/range);
- image->colormap[i].blue=ClampToQuantum(((double) QuantumRange*
- blue_colormap[i])/range);
- }
+ }
}
quantum_type=IndexQuantum;
pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
if (image->storage_class != PseudoClass)
{
int
status;
- register PixelPacket
+ register Quantum
*restrict q;
status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels);
if (status == -1)
break;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
quantum_type,pixels,exception);
*/
pad=(size_t) MagickMax((size_t) samples_per_pixel-3,0);
quantum_type=RGBQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
quantum_type=RGBAQuantum;
pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);
{
pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);
quantum_type=CMYKQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
quantum_type=CMYKAQuantum;
pad=(size_t) MagickMax((size_t) samples_per_pixel-5,0);
int
status;
- register PixelPacket
+ register Quantum
*restrict q;
status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels);
if (status == -1)
break;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
quantum_type,pixels,exception);
{
for (y=0; y < (ssize_t) image->rows; y++)
{
- register PixelPacket
+ register Quantum
*restrict q;
int
if (status == -1)
break;
q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
if (image->colorspace != CMYKColorspace)
switch (i)
}
case ReadStripMethod:
{
- register unsigned char
+ register uint32
*p;
/*
Convert stripped TIFF image to DirectClass MIFF image.
*/
i=0;
- p=(unsigned char *) NULL;
+ p=(uint32 *) NULL;
for (y=0; y < (ssize_t) image->rows; y++)
{
register ssize_t
x;
- register PixelPacket
+ register Quantum
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
if (i == 0)
{
p=((uint32 *) pixels)+image->columns*i;
for (x=0; x < (ssize_t) image->columns; x++)
{
- q->red=ScaleCharToQuantum((unsigned char) (TIFFGetR(*p)));
- q->green=ScaleCharToQuantum((unsigned char) (TIFFGetG(*p)));
- q->blue=ScaleCharToQuantum((unsigned char) (TIFFGetB(*p)));
- if (image->matte != MagickFalse)
- q->opacity=ScaleCharToQuantum((unsigned char) (TIFFGetA(*p)));
+ SetPixelRed(image,ScaleCharToQuantum((unsigned char)
+ (TIFFGetR(*p))),q);
+ SetPixelGreen(image,ScaleCharToQuantum((unsigned char)
+ (TIFFGetG(*p))),q);
+ SetPixelBlue(image,ScaleCharToQuantum((unsigned char)
+ (TIFFGetB(*p))),q);
+ if (image->alpha_trait == BlendPixelTrait)
+ SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)
+ (TIFFGetA(*p))),q);
p++;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
TIFFClose(tiff);
ThrowReaderException(CoderError,"ImageIsNotTiled");
}
- (void) SetImageStorageClass(image,DirectClass);
+ (void) SetImageStorageClass(image,DirectClass,exception);
number_pixels=columns*rows;
tile_pixels=(uint32 *) AcquireQuantumMemory(number_pixels,
sizeof(*tile_pixels));
}
for (y=0; y < (ssize_t) image->rows; y+=rows)
{
- PixelPacket
- *tile;
-
register ssize_t
x;
- register PixelPacket
- *restrict q;
+ register Quantum
+ *restrict q,
+ *restrict tile;
size_t
columns_remaining,
rows_remaining=rows;
tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining,
exception);
- if (tile == (PixelPacket *) NULL)
+ if (tile == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x+=columns)
{
if ((ssize_t) (x+columns) < (ssize_t) image->columns)
columns_remaining=columns;
p=tile_pixels+(rows-rows_remaining)*columns;
- q=tile+(image->columns*(rows_remaining-1)+x);
+ q=tile+GetPixelChannels(image)*(image->columns*(rows_remaining-1)+
+ x);
for (row=rows_remaining; row > 0; row--)
{
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
for (column=columns_remaining; column > 0; column--)
{
- q->red=ScaleCharToQuantum((unsigned char) TIFFGetR(*p));
- q->green=ScaleCharToQuantum((unsigned char) TIFFGetG(*p));
- q->blue=ScaleCharToQuantum((unsigned char) TIFFGetB(*p));
- q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(
- (unsigned char) TIFFGetA(*p)));
- q++;
+ SetPixelRed(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetR(*p)),q);
+ SetPixelGreen(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetG(*p)),q);
+ SetPixelBlue(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetB(*p)),q);
+ SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetA(*p)),q);
p++;
+ q+=GetPixelChannels(image);
}
else
for (column=columns_remaining; column > 0; column--)
{
- q->red=ScaleCharToQuantum((unsigned char) TIFFGetR(*p));
- q->green=ScaleCharToQuantum((unsigned char) TIFFGetG(*p));
- q->blue=ScaleCharToQuantum((unsigned char) TIFFGetB(*p));
- q++;
+ SetPixelRed(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetR(*p)),q);
+ SetPixelGreen(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetG(*p)),q);
+ SetPixelBlue(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetB(*p)),q);
p++;
+ q+=GetPixelChannels(image);
}
p+=columns-columns_remaining;
- q-=(image->columns+columns_remaining);
+ q-=GetPixelChannels(image)*(image->columns+columns_remaining);
}
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
register ssize_t
x;
- register PixelPacket
+ register Quantum
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- q+=image->columns-1;
+ q+=GetPixelChannels(image)*(image->columns-1);
for (x=0; x < (ssize_t) image->columns; x++)
{
- q->red=ScaleCharToQuantum((unsigned char) TIFFGetR(*p));
- q->green=ScaleCharToQuantum((unsigned char) TIFFGetG(*p));
- q->blue=ScaleCharToQuantum((unsigned char) TIFFGetB(*p));
- if (image->matte != MagickFalse)
- q->opacity=(Quantum) (QuantumRange-
- ScaleCharToQuantum((unsigned char) TIFFGetA(*p)));
+ SetPixelRed(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetR(*p)),q);
+ SetPixelGreen(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetG(*p)),q);
+ SetPixelBlue(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetB(*p)),q);
+ if (image->alpha_trait == BlendPixelTrait)
+ SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)
+ TIFFGetA(*p)),q);
p--;
- q--;
+ q-=GetPixelChannels(image);;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
SetQuantumImageType(image,quantum_type);
next_tiff_frame:
+ quantum_info=DestroyQuantumInfo(quantum_info);
+ if (photometric == PHOTOMETRIC_CIELAB)
+ DecodeLabImage(image,exception);
if ((photometric == PHOTOMETRIC_LOGL) ||
(photometric == PHOTOMETRIC_MINISBLACK) ||
(photometric == PHOTOMETRIC_MINISWHITE))
}
if (image->storage_class == PseudoClass)
image->depth=GetImageDepth(image,exception);
- image->endian=MSBEndian;
- if (endian == FILLORDER_LSB2MSB)
- image->endian=LSBEndian;
- if ((photometric == PHOTOMETRIC_LOGL) ||
- (photometric == PHOTOMETRIC_MINISBLACK) ||
- (photometric == PHOTOMETRIC_MINISWHITE))
- {
- image->type=GrayscaleType;
- if (bits_per_sample == 1)
- image->type=BilevelType;
- }
/*
Proceed to next image.
*/
/*
Allocate next image structure.
*/
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
if (status == MagickFalse)
break;
}
- quantum_info=DestroyQuantumInfo(quantum_info);
} while (status == MagickTrue);
(void) TIFFSetWarningHandler(warning_handler);
(void) TIFFSetErrorHandler(error_handler);
% size_t RegisterTIFFImage(void)
%
*/
+
+#if defined(MAGICKCORE_HAVE_TIFFMERGEFIELDINFO) && defined(MAGICKCORE_HAVE_TIFFSETTAGEXTENDER)
+static TIFFExtendProc
+ tag_extender = (TIFFExtendProc) NULL;
+
+static void TIFFTagExtender(TIFF *tiff)
+{
+ static const TIFFFieldInfo
+ TIFFExtensions[] =
+ {
+ { 37724, -3, -3, TIFF_UNDEFINED, FIELD_CUSTOM, 1, 1,
+ (char *) "PhotoshopLayerData" },
+ { 34118, -3, -3, TIFF_UNDEFINED, FIELD_CUSTOM, 1, 1,
+ (char *) "Microscope" }
+ };
+
+ TIFFMergeFieldInfo(tiff,TIFFExtensions,sizeof(TIFFExtensions)/
+ sizeof(*TIFFExtensions));
+ if (tag_extender != (TIFFExtendProc) NULL)
+ (*tag_extender)(tiff);
+}
+#endif
+
ModuleExport size_t RegisterTIFFImage(void)
{
#define TIFFDescription "Tagged Image File Format"
{
if (MagickCreateThreadKey(&tiff_exception) == MagickFalse)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+#if defined(MAGICKCORE_HAVE_TIFFMERGEFIELDINFO) && defined(MAGICKCORE_HAVE_TIFFSETTAGEXTENDER)
+ if (tag_extender == (TIFFExtendProc) NULL)
+ tag_extender=TIFFSetTagExtender(TIFFTagExtender);
+#endif
instantiate_key=MagickTrue;
}
UnlockSemaphoreInfo(tiff_semaphore);
*version='\0';
#if defined(TIFF_VERSION)
- (void) FormatMagickString(version,MaxTextExtent,"%d",TIFF_VERSION);
+ (void) FormatLocaleString(version,MaxTextExtent,"%d",TIFF_VERSION);
#endif
#if defined(MAGICKCORE_TIFF_DELEGATE)
{
entry=SetMagickInfo("TIFF64");
#if defined(TIFF_VERSION_BIG)
entry->decoder=(DecodeImageHandler *) ReadTIFFImage;
- entry->encoder=(EncodeImageHandler *) WritePTIFImage;
+ entry->encoder=(EncodeImageHandler *) WriteTIFFImage;
#endif
entry->adjoin=MagickFalse;
entry->endian_support=MagickTrue;
*/
ModuleExport void UnregisterTIFFImage(void)
{
- (void) UnregisterMagickInfo("RAWGROUP4");
- (void) UnregisterMagickInfo("PTIF");
- (void) UnregisterMagickInfo("TIF");
- (void) UnregisterMagickInfo("TIFF");
(void) UnregisterMagickInfo("TIFF64");
+ (void) UnregisterMagickInfo("TIFF");
+ (void) UnregisterMagickInfo("TIF");
+ (void) UnregisterMagickInfo("PTIF");
if (tiff_semaphore == (SemaphoreInfo *) NULL)
tiff_semaphore=AllocateSemaphoreInfo();
LockSemaphoreInfo(tiff_semaphore);
if (instantiate_key != MagickFalse)
- if (MagickDeleteThreadKey(tiff_exception) == MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- instantiate_key=MagickFalse;
+ {
+#if defined(MAGICKCORE_HAVE_TIFFMERGEFIELDINFO) && defined(MAGICKCORE_HAVE_TIFFSETTAGEXTENDER)
+ if (tag_extender == (TIFFExtendProc) NULL)
+ (void) TIFFSetTagExtender(tag_extender);
+#endif
+ if (MagickDeleteThreadKey(tiff_exception) == MagickFalse)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ instantiate_key=MagickFalse;
+ }
UnlockSemaphoreInfo(tiff_semaphore);
DestroySemaphoreInfo(&tiff_semaphore);
}
% The format of the WriteGROUP4Image method is:
%
% MagickBooleanType WriteGROUP4Image(const ImageInfo *image_info,
-% Image *image)
+% Image *image,ExceptionInfo *)
%
% A description of each parameter follows:
%
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static MagickBooleanType WriteGROUP4Image(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
char
filename[MaxTextExtent];
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- huffman_image=CloneImage(image,0,0,MagickTrue,&image->exception);
+ huffman_image=CloneImage(image,0,0,MagickTrue,exception);
if (huffman_image == (Image *) NULL)
{
(void) CloseBlob(image);
file=fdopen(unique_file,"wb");
if ((unique_file == -1) || (file == (FILE *) NULL))
{
- ThrowFileException(&image->exception,FileOpenError,
- "UnableToCreateTemporaryFile",filename);
+ ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
+ filename);
return(MagickFalse);
}
- (void) FormatMagickString(huffman_image->filename,MaxTextExtent,"tiff:%s",
+ (void) FormatLocaleString(huffman_image->filename,MaxTextExtent,"tiff:%s",
filename);
- (void) SetImageType(huffman_image,BilevelType);
+ (void) SetImageType(huffman_image,BilevelType,exception);
write_info=CloneImageInfo((ImageInfo *) NULL);
SetImageInfoFile(write_info,file);
write_info->compression=Group4Compression;
write_info->type=BilevelType;
(void) SetImageOption(write_info,"quantum:polarity","min-is-white");
- status=WriteTIFFImage(write_info,huffman_image);
+ status=WriteTIFFImage(write_info,huffman_image,exception);
(void) fflush(file);
write_info=DestroyImageInfo(write_info);
if (status == MagickFalse)
{
- InheritException(&image->exception,&huffman_image->exception);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
- ThrowFileException(&image->exception,FileOpenError,"UnableToOpenFile",
+ ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
image_info->filename);
return(MagickFalse);
}
% The format of the WritePTIFImage method is:
%
% MagickBooleanType WritePTIFImage(const ImageInfo *image_info,
-% Image *image)
+% Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static MagickBooleanType WritePTIFImage(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
Image
*images,
MagickBooleanType
status;
+ PointInfo
+ resolution;
+
size_t
columns,
rows;
images=NewImageList();
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
{
- AppendImageToList(&images,CloneImage(next,0,0,MagickFalse,
- &image->exception));
+ AppendImageToList(&images,CloneImage(next,0,0,MagickFalse,exception));
columns=next->columns;
rows=next->rows;
+ resolution=next->resolution;
while ((columns > 64) && (rows > 64))
{
columns/=2;
rows/=2;
- pyramid_image=ResizeImage(next,columns,rows,UndefinedFilter,image->blur,
- &image->exception);
+ resolution.x/=2;
+ resolution.y/=2;
+ pyramid_image=ResizeImage(next,columns,rows,image->filter,exception);
+ if (pyramid_image == (Image *) NULL)
+ break;
+ pyramid_image->resolution=resolution;
AppendImageToList(&images,pyramid_image);
}
}
+ images=GetFirstImageInList(images);
/*
Write pyramid-encoded TIFF image.
*/
write_info=CloneImageInfo(image_info);
- *write_info->magick='\0';
write_info->adjoin=MagickTrue;
- status=WriteTIFFImage(write_info,GetFirstImageInList(images));
+ (void) CopyMagickString(write_info->magick,"TIFF",MaxTextExtent);
+ (void) CopyMagickString(images->magick,"TIFF",MaxTextExtent);
+ status=WriteTIFFImage(write_info,images,exception);
images=DestroyImageList(images);
write_info=DestroyImageInfo(write_info);
return(status);
% The format of the WriteTIFFImage method is:
%
% MagickBooleanType WriteTIFFImage(const ImageInfo *image_info,
-% Image *image)
+% Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
typedef struct _TIFFInfo
tiff_info->pixels);
}
+static MagickBooleanType EncodeLabImage(Image *image,ExceptionInfo *exception)
+{
+ CacheView
+ *image_view;
+
+ MagickBooleanType
+ status;
+
+ ssize_t
+ y;
+
+ status=MagickTrue;
+ image_view=AcquireAuthenticCacheView(image,exception);
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (status == MagickFalse)
+ continue;
+ q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ if (q == (Quantum *) NULL)
+ {
+ status=MagickFalse;
+ continue;
+ }
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ double
+ a,
+ b;
+
+ a=QuantumScale*GetPixela(image,q)-0.5;
+ if (a < 0.0)
+ a+=1.0;
+ b=QuantumScale*GetPixelb(image,q)-0.5;
+ if (b < 0.0)
+ b+=1.0;
+ SetPixela(image,QuantumRange*a,q);
+ SetPixelb(image,QuantumRange*b,q);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ status=MagickFalse;
+ }
+ image_view=DestroyCacheView(image_view);
+ return(status);
+}
+
static MagickBooleanType GetTIFFInfo(const ImageInfo *image_info,TIFF *tiff,
TIFFInfo *tiff_info)
{
int32
status;
- ssize_t
- bytes_per_pixel,
- j,
- k,
- l;
-
register ssize_t
i;
number_tiles,
tile_width;
+ ssize_t
+ bytes_per_pixel,
+ j,
+ k,
+ l;
+
if (TIFFIsTiled(tiff) == 0)
return(TIFFWriteScanline(tiff,tiff_info->scanline,(uint32) row,sample));
/*
(void) CopyMagickMemory(tiff_info->scanlines+i,(char *) tiff_info->scanline,
(size_t) TIFFScanlineSize(tiff));
if (((size_t) (row % tiff_info->tile_geometry.height) !=
- (tiff_info->tile_geometry.height-1)) && (row != (ssize_t) (image->rows-1)))
+ (tiff_info->tile_geometry.height-1)) &&
+ (row != (ssize_t) (image->rows-1)))
return(0);
/*
Write tile to TIFF image.
*/
status=0;
- bytes_per_pixel=TIFFTileSize(tiff)/(ssize_t) (tiff_info->tile_geometry.height*
- tiff_info->tile_geometry.width);
+ bytes_per_pixel=TIFFTileSize(tiff)/(ssize_t) (
+ tiff_info->tile_geometry.height*tiff_info->tile_geometry.width);
number_tiles=(image->columns+tiff_info->tile_geometry.width)/
tiff_info->tile_geometry.width;
for (i=0; i < (ssize_t) number_tiles; i++)
GetStringInfoLength(profile),GetStringInfoDatum(profile));
#endif
if (LocaleCompare(name,"tiff:37724") == 0)
- (void) TIFFSetField(tiff,37724,(uint32)GetStringInfoLength(profile),
+ (void) TIFFSetField(tiff,37724,(uint32) GetStringInfoLength(profile),
+ GetStringInfoDatum(profile));
+ if (LocaleCompare(name,"tiff:34118") == 0)
+ (void) TIFFSetField(tiff,34118,(uint32) GetStringInfoLength(profile),
GetStringInfoDatum(profile));
name=GetNextImageProfile(image);
}
}
-static void TIFFSetProperties(TIFF *tiff,Image *image)
+static void TIFFSetProperties(TIFF *tiff,Image *image,ExceptionInfo *exception)
{
const char
*value;
(void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
- value=GetImageProperty(image,"tiff:hostcomputer");
+ value=GetImageProperty(image,"tiff:hostcomputer",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_HOSTCOMPUTER,value);
- value=GetImageProperty(image,"tiff:artist");
+ value=GetImageProperty(image,"tiff:artist",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_ARTIST,value);
- value=GetImageProperty(image,"tiff:timestamp");
+ value=GetImageProperty(image,"tiff:timestamp",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_DATETIME,value);
- value=GetImageProperty(image,"tiff:make");
+ value=GetImageProperty(image,"tiff:make",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_MAKE,value);
- value=GetImageProperty(image,"tiff:model");
+ value=GetImageProperty(image,"tiff:model",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_MODEL,value);
- value=GetImageProperty(image,"tiff:software");
+ value=GetImageProperty(image,"tiff:software",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,value);
- value=GetImageProperty(image,"tiff:copyright");
+ value=GetImageProperty(image,"tiff:copyright",exception);
if (value != (const char *) NULL)
- (void) TIFFSetField(tiff,33432,value);
- value=GetImageProperty(image,"kodak-33423");
+ (void) TIFFSetField(tiff,TIFFTAG_COPYRIGHT,value);
+ value=GetImageProperty(image,"kodak-33423",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,33423,value);
- value=GetImageProperty(image,"kodak-36867");
+ value=GetImageProperty(image,"kodak-36867",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,36867,value);
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_PAGENAME,value);
- value=GetImageProperty(image,"comment");
+ value=GetImageProperty(image,"comment",exception);
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_IMAGEDESCRIPTION,value);
}
-static void TIFFSetEXIFProperties(TIFF *tiff,Image *image)
+static void TIFFSetEXIFProperties(TIFF *tiff,Image *image,
+ ExceptionInfo *exception)
{
#if defined(MAGICKCORE_HAVE_TIFFREADEXIFDIRECTORY)
const char
(void) TIFFSetField(tiff,TIFFTAG_SUBIFD,1,&offset);
for (i=0; exif_info[i].tag != 0; i++)
{
- value=GetImageProperty(image,exif_info[i].property);
+ value=GetImageProperty(image,exif_info[i].property,exception);
if (value == (const char *) NULL)
continue;
switch (exif_info[i].type)
float
rational;
- rational=StringToDouble(value);
+ rational=StringToDouble(value,(char **) NULL);
(void) TIFFSetField(tiff,exif_info[i].tag,rational);
break;
}
}
static MagickBooleanType WriteTIFFImage(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
#if !defined(TIFFDefaultStripSize)
#define TIFFDefaultStripSize(tiff,request) (8192UL/TIFFScanlineSize(tiff))
EndianType
endian_type;
- ssize_t
- y;
-
MagickBooleanType
debug,
status;
i;
size_t
- length,
- lsb_first;
+ length;
+
+ ssize_t
+ y;
TIFF
*tiff;
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- (void) MagickSetThreadValue(tiff_exception,&image->exception);
+ (void) MagickSetThreadValue(tiff_exception,exception);
error_handler=TIFFSetErrorHandler((TIFFErrorHandler) TIFFErrors);
warning_handler=TIFFSetWarningHandler((TIFFErrorHandler) TIFFWarnings);
endian_type=UndefinedEndian;
- option=GetImageOption(image_info,"tiff:endian");
+ option=GetImageArtifact(image,"tiff:endian");
if (option != (const char *) NULL)
{
if (LocaleNCompare(option,"msb",3) == 0)
*/
if ((image_info->type != UndefinedType) &&
(image_info->type != OptimizeType))
- (void) SetImageType(image,image_info->type);
+ (void) SetImageType(image,image_info->type,exception);
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
if ((image->storage_class != PseudoClass) && (image->depth >= 32) &&
(quantum_info->format == UndefinedQuantumFormat) &&
- (IsHighDynamicRangeImage(image,&image->exception) != MagickFalse))
+ (IsHighDynamicRangeImage(image,exception) != MagickFalse))
{
status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);
if (status == MagickFalse)
SetQuantumMinIsWhite(quantum_info,MagickTrue);
break;
}
+#if defined(COMPRESSION_JBIG)
+ case JBIG1Compression:
+ {
+ compress_tag=COMPRESSION_JBIG;
+ break;
+ }
+#endif
case JPEGCompression:
{
compress_tag=COMPRESSION_JPEG;
if ((compress_tag != COMPRESSION_NONE) &&
(TIFFIsCODECConfigured(compress_tag) == 0))
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
+ (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
+ "CompressionNotSupported","`%s'",CommandOptionToMnemonic(
MagickCompressOptions,(ssize_t) compression));
compress_tag=COMPRESSION_NONE;
compression=NoCompression;
break;
default:
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
+ (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
+ "CompressionNotSupported","`%s'",CommandOptionToMnemonic(
MagickCompressOptions,(ssize_t) compression));
compress_tag=COMPRESSION_NONE;
compression=NoCompression;
case FaxCompression:
case Group4Compression:
{
- (void) SetImageType(image,BilevelType);
+ (void) SetImageType(image,BilevelType,exception);
break;
}
case JPEGCompression:
{
- (void) SetImageStorageClass(image,DirectClass);
- (void) SetImageDepth(image,8);
+ (void) SetImageStorageClass(image,DirectClass,exception);
+ (void) SetImageDepth(image,8,exception);
break;
}
default:
Full color TIFF raster.
*/
if (image->colorspace == LabColorspace)
- photometric=PHOTOMETRIC_CIELAB;
+ {
+ photometric=PHOTOMETRIC_CIELAB;
+ EncodeLabImage(image,exception);
+ }
else
if (image->colorspace == YCbCrColorspace)
{
photometric=PHOTOMETRIC_YCBCR;
(void) TIFFSetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,1,1);
- (void) SetImageStorageClass(image,DirectClass);
- (void) SetImageDepth(image,8);
+ (void) SetImageStorageClass(image,DirectClass,exception);
+ (void) SetImageDepth(image,8,exception);
}
else
- {
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
- photometric=PHOTOMETRIC_RGB;
- }
+ photometric=PHOTOMETRIC_RGB;
(void) TIFFSetField(tiff,TIFFTAG_SAMPLESPERPIXEL,3);
if ((image_info->type != TrueColorType) &&
(image_info->type != TrueColorMatteType))
{
if ((image_info->type != PaletteType) &&
- (IsGrayImage(image,&image->exception) != MagickFalse))
+ (IsImageGray(image,exception) != MagickFalse))
{
photometric=(uint16) (quantum_info->min_is_white !=
MagickFalse ? PHOTOMETRIC_MINISWHITE :
PHOTOMETRIC_MINISBLACK);
(void) TIFFSetField(tiff,TIFFTAG_SAMPLESPERPIXEL,1);
- if ((image_info->depth == 0) && (image->matte == MagickFalse) &&
- (IsMonochromeImage(image,&image->exception) != MagickFalse))
+ if ((image_info->depth == 0) &&
+ (image->alpha_trait != BlendPixelTrait) &&
+ (IsImageMonochrome(image,exception) != MagickFalse))
{
status=SetQuantumDepth(image,quantum_info,1);
if (status == MagickFalse)
}
}
}
+ if ((photometric == PHOTOMETRIC_RGB) &&
+ (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse))
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
switch (image->endian)
{
case LSBEndian:
break;
}
}
- lsb_first=1;
- image->endian=MSBEndian;
- if ((int) (*(char *) &lsb_first) != 0)
- image->endian=LSBEndian;
if ((compress_tag == COMPRESSION_CCITTFAX3) &&
(photometric != PHOTOMETRIC_MINISWHITE))
{
compress_tag=COMPRESSION_NONE;
endian=FILLORDER_MSB2LSB;
}
- option=GetImageProperty(image,"tiff:fill-order");
+ option=GetImageArtifact(image,"tiff:fill-order");
if (option != (const char *) NULL)
{
if (LocaleNCompare(option,"msb",3) == 0)
(void) TIFFSetField(tiff,TIFFTAG_COMPRESSION,compress_tag);
(void) TIFFSetField(tiff,TIFFTAG_FILLORDER,endian);
(void) TIFFSetField(tiff,TIFFTAG_BITSPERSAMPLE,quantum_info->depth);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
uint16
extra_samples,
*/
extra_samples=1;
sample_info[0]=EXTRASAMPLE_UNASSALPHA;
- option=GetImageProperty(image,"tiff:alpha");
+ option=GetImageArtifact(image,"tiff:alpha");
if ((option != (const char *) NULL) &&
(LocaleCompare(option,"associated") == 0))
sample_info[0]=EXTRASAMPLE_ASSOCALPHA;
if (TIFFScanlineSize(tiff) != 0)
rows_per_strip=(uint32) MagickMax((size_t) TIFFDefaultStripSize(tiff,0),
1);
- option=GetImageOption(image_info,"tiff:rows-per-strip");
+ option=GetImageArtifact(image,"tiff:rows-per-strip");
if (option != (const char *) NULL)
rows_per_strip=(size_t) strtol(option,(char **) NULL,10);
switch (compress_tag)
if (image_info->quality != UndefinedCompressionQuality)
(void) TIFFSetField(tiff,TIFFTAG_JPEGQUALITY,image_info->quality);
(void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RAW);
- if (image->colorspace == RGBColorspace)
+ if (IssRGBCompatibleColorspace(image->colorspace) != MagickFalse)
{
const char
*value;
(void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB);
sampling_factor=(const char *) NULL;
- value=GetImageProperty(image,"jpeg:sampling-factor");
+ value=GetImageProperty(image,"jpeg:sampling-factor",exception);
if (value != (char *) NULL)
{
sampling_factor=value;
default:
break;
}
- option=GetImageOption(image_info,"tiff:tile-geometry");
+ option=GetImageArtifact(image,"tiff:rows-per-strip");
if (option == (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);
- if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
+ if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
{
unsigned short
units;
if (image->units == PixelsPerCentimeterResolution)
units=RESUNIT_CENTIMETER;
(void) TIFFSetField(tiff,TIFFTAG_RESOLUTIONUNIT,(uint16) units);
- (void) TIFFSetField(tiff,TIFFTAG_XRESOLUTION,image->x_resolution);
- (void) TIFFSetField(tiff,TIFFTAG_YRESOLUTION,image->y_resolution);
- if ((image->page.x != 0) || (image->page.y != 0))
+ (void) TIFFSetField(tiff,TIFFTAG_XRESOLUTION,image->resolution.x);
+ (void) TIFFSetField(tiff,TIFFTAG_YRESOLUTION,image->resolution.y);
+ if ((image->page.x > 0) && (image->page.y > 0))
{
/*
Set image position.
*/
(void) TIFFSetField(tiff,TIFFTAG_XPOSITION,(float) image->page.x/
- image->x_resolution);
+ image->resolution.x);
(void) TIFFSetField(tiff,TIFFTAG_YPOSITION,(float) image->page.y/
- image->y_resolution);
+ image->resolution.y);
}
}
if (image->chromaticity.white_point.x != 0.0)
chromaticity[1]=(float) image->chromaticity.white_point.y;
(void) TIFFSetField(tiff,TIFFTAG_WHITEPOINT,chromaticity);
}
- if ((image_info->adjoin != MagickFalse) && (GetImageListLength(image) > 1))
+ if ((LocaleCompare(image_info->magick,"PTIF") != 0) &&
+ (image_info->adjoin != MagickFalse) && (GetImageListLength(image) > 1))
{
(void) TIFFSetField(tiff,TIFFTAG_SUBFILETYPE,FILETYPE_PAGE);
if (image->scene != 0)
page=(uint16) scene;
pages=(uint16) GetImageListLength(image);
- if ((image_info->adjoin != MagickFalse) && (pages > 1))
+ if ((LocaleCompare(image_info->magick,"PTIF") != 0) &&
+ (image_info->adjoin != MagickFalse) && (pages > 1))
(void) TIFFSetField(tiff,TIFFTAG_SUBFILETYPE,FILETYPE_PAGE);
(void) TIFFSetField(tiff,TIFFTAG_PAGENUMBER,page,pages);
}
- (void) TIFFSetProperties(tiff,image);
+ (void) TIFFSetProperties(tiff,image,exception);
if (0)
- (void) TIFFSetEXIFProperties(tiff,image);
+ (void) TIFFSetEXIFProperties(tiff,image,exception);
/*
Write image scanlines.
*/
if (GetTIFFInfo(image_info,tiff,&tiff_info) == MagickFalse)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ quantum_info->endian=LSBEndian;
pixels=GetQuantumPixels(quantum_info);
tiff_info.scanline=GetQuantumPixels(quantum_info);
switch (photometric)
default:
{
quantum_type=RGBQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
quantum_type=RGBAQuantum;
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_type,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ quantum_type,pixels,exception);
(void) length;
if (TIFFWritePixels(tiff,&tiff_info,y,0,image) == -1)
break;
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,RedQuantum,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ RedQuantum,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,0,image) == -1)
break;
}
}
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,GreenQuantum,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ GreenQuantum,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,1,image) == -1)
break;
}
}
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,BlueQuantum,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ BlueQuantum,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,2,image) == -1)
break;
}
if (status == MagickFalse)
break;
}
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,
- &image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,AlphaQuantum,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,
+ quantum_info,AlphaQuantum,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,3,image) == -1)
break;
}
CMYK TIFF image.
*/
quantum_type=CMYKQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
quantum_type=CMYKAQuantum;
if (image->colorspace != CMYKColorspace)
- (void) TransformImageColorspace(image,CMYKColorspace);
+ (void) TransformImageColorspace(image,CMYKColorspace,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_type,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ quantum_type,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,0,image) == -1)
break;
if (image->previous == (Image *) NULL)
Convert PseudoClass packets to contiguous grayscale scanlines.
*/
quantum_type=IndexQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
if (photometric != PHOTOMETRIC_PALETTE)
quantum_type=GrayAlphaQuantum;
quantum_type=GrayQuantum;
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_type,pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ quantum_type,pixels,exception);
if (TIFFWritePixels(tiff,&tiff_info,y,0,image) == -1)
break;
if (image->previous == (Image *) NULL)
}
}
quantum_info=DestroyQuantumInfo(quantum_info);
+ if (image->colorspace == LabColorspace)
+ DecodeLabImage(image,exception);
DestroyTIFFInfo(&tiff_info);
if (0 && (image_info->verbose == MagickTrue))
TIFFPrintDirectory(tiff,stdout,MagickFalse);
(void) TIFFWriteDirectory(tiff);
- image->endian=MSBEndian;
- if (endian == FILLORDER_LSB2MSB)
- image->endian=LSBEndian;
image=SyncNextImageInList(image);
if (image == (Image *) NULL)
break;