% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
offset=(ssize_t) fseek(file,(ssize_t) offset,SEEK_SET);
length=WriteLSBLong(file,(unsigned int) length);
if (ferror(file) != 0)
- ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
+ {
+ (void) fclose(file);
+ ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
+ }
(void) fclose(file);
(void) CloseBlob(image);
image=DestroyImage(image);
return((toff_t) GetBlobSize((Image *) image));
}
-static void TIFFGetProfiles(TIFF *tiff,Image *image,MagickBooleanType ping,
- ExceptionInfo *exception)
+static void TIFFGetProfiles(TIFF *tiff,Image *image,ExceptionInfo *exception)
{
uint32
length;
*profile;
length=0;
- if (ping == MagickFalse)
- {
#if defined(TIFFTAG_ICCPROFILE)
- if ((TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1) &&
- (profile != (unsigned char *) NULL))
- (void) ReadProfile(image,"icc",profile,(ssize_t) length,exception);
+ if ((TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1) &&
+ (profile != (unsigned char *) NULL))
+ (void) ReadProfile(image,"icc",profile,(ssize_t) length,exception);
#endif
#if defined(TIFFTAG_PHOTOSHOP)
- if ((TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1) &&
- (profile != (unsigned char *) NULL))
- (void) ReadProfile(image,"8bim",profile,(ssize_t) length,exception);
+ if ((TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1) &&
+ (profile != (unsigned char *) NULL))
+ (void) ReadProfile(image,"8bim",profile,(ssize_t) length,exception);
#endif
#if defined(TIFFTAG_RICHTIFFIPTC)
- if ((TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1) &&
- (profile != (unsigned char *) NULL))
- {
- if (TIFFIsByteSwapped(tiff) != 0)
- TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length);
- (void) ReadProfile(image,"iptc",profile,4L*length,exception);
- }
+ if ((TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1) &&
+ (profile != (unsigned char *) NULL))
+ {
+ if (TIFFIsByteSwapped(tiff) != 0)
+ TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length);
+ (void) ReadProfile(image,"iptc",profile,4L*length,exception);
+ }
#endif
#if defined(TIFFTAG_XMLPACKET)
- if ((TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1) &&
- (profile != (unsigned char *) NULL))
- (void) ReadProfile(image,"xmp",profile,(ssize_t) length,exception);
+ if ((TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1) &&
+ (profile != (unsigned char *) NULL))
+ (void) ReadProfile(image,"xmp",profile,(ssize_t) length,exception);
#endif
- if ((TIFFGetField(tiff,34118,&length,&profile) == 1) &&
- (profile != (unsigned char *) NULL))
- (void) ReadProfile(image,"tiff:34118",profile,(ssize_t) length,
- exception);
- }
+ if ((TIFFGetField(tiff,34118,&length,&profile) == 1) &&
+ (profile != (unsigned char *) NULL))
+ (void) ReadProfile(image,"tiff:34118",profile,(ssize_t) length,
+ exception);
if ((TIFFGetField(tiff,37724,&length,&profile) == 1) &&
(profile != (unsigned char *) NULL))
(void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length,exception);
SetImageColorspace(image,CMYKColorspace,exception);
if (photometric == PHOTOMETRIC_CIELAB)
SetImageColorspace(image,LabColorspace,exception);
- TIFFGetProfiles(tiff,image,image_info->ping,exception);
+ TIFFGetProfiles(tiff,image,exception);
TIFFGetProperties(tiff,image,exception);
option=GetImageOption(image_info,"tiff:exif-properties");
if (IsStringFalse(option) == MagickFalse) /* enabled by default */
(void) SetImageProperty(image,"tiff:rows-per-strip",value,exception);
}
if ((samples_per_pixel >= 3) && (interlace == PLANARCONFIG_CONTIG))
- method=ReadRGBAMethod;
+ if ((image->alpha_trait == UndefinedPixelTrait) ||
+ (samples_per_pixel >= 4))
+ method=ReadRGBAMethod;
if ((samples_per_pixel >= 4) && (interlace == PLANARCONFIG_SEPARATE))
- method=ReadCMYKAMethod;
+ if ((image->alpha_trait == UndefinedPixelTrait) ||
+ (samples_per_pixel >= 5))
+ method=ReadCMYKAMethod;
if ((photometric != PHOTOMETRIC_RGB) &&
(photometric != PHOTOMETRIC_CIELAB) &&
(photometric != PHOTOMETRIC_SEPARATED))
quantum_info->endian=LSBEndian;
quantum_type=RGBQuantum;
tiff_pixels=(unsigned char *) AcquireMagickMemory(MagickMax(
- TIFFScanlineSize(tiff),(size_t) (image->columns*samples_per_pixel*
+ TIFFScanlineSize(tiff),(ssize_t) (image->columns*samples_per_pixel*
pow(2.0,ceil(log(bits_per_sample)/log(2.0))))));
if (tiff_pixels == (unsigned char *) NULL)
{
AppendImageToList(&images,pyramid_image);
}
}
- images=GetFirstImageInList(images);
- /*
- Write pyramid-encoded TIFF image.
- */
- write_info=CloneImageInfo(image_info);
- write_info->adjoin=MagickTrue;
- (void) CopyMagickString(write_info->magick,"TIFF",MagickPathExtent);
- (void) CopyMagickString(images->magick,"TIFF",MagickPathExtent);
- status=WriteTIFFImage(write_info,images,exception);
- images=DestroyImageList(images);
- write_info=DestroyImageInfo(write_info);
+ status=MagickFalse;
+ if (images != (Image *) NULL)
+ {
+ /*
+ Write pyramid-encoded TIFF image.
+ */
+ images=GetFirstImageInList(images);
+ write_info=CloneImageInfo(image_info);
+ write_info->adjoin=MagickTrue;
+ (void) CopyMagickString(write_info->magick,"TIFF",MagickPathExtent);
+ (void) CopyMagickString(images->magick,"TIFF",MagickPathExtent);
+ status=WriteTIFFImage(write_info,images,exception);
+ images=DestroyImageList(images);
+ write_info=DestroyImageInfo(write_info);
+ }
return(status);
}
#endif