(void) ConcatenateMagickString(message,".",MaxTextExtent);
exception=(ExceptionInfo *) MagickGetThreadValue(tiff_exception);
if (exception != (ExceptionInfo *) NULL)
- (void) ThrowMagickException(exception,GetMagickModule(),CoderWarning,
- message,"`%s'",module);
+ (void) ThrowMagickException(exception,GetMagickModule(),CoderError,message,
+ "`%s'",module);
}
static void TIFFGetProfiles(TIFF *tiff,Image *image)
{
if (0 && (image_info->verbose != MagickFalse))
TIFFPrintDirectory(tiff,stdout,MagickFalse);
+ (void) SetImageProperty(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ?
+ "lsb" : "msb");
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_IMAGEWIDTH,&width);
(void) SetImageProperty(image,"tiff:photometric","separated");
break;
}
+ case PHOTOMETRIC_YCBCR:
+ {
+ (void) SetImageProperty(image,"tiff:photometric","YCBCR");
+ break;
+ }
default:
{
(void) SetImageProperty(image,"tiff:photometric","unknown");
if ((photometric != PHOTOMETRIC_SEPARATED) &&
(interlace == PLANARCONFIG_SEPARATE))
method=ReadGenericMethod;
+ if (image->compression == JPEGCompression)
+ method=ReadGenericMethod;
if (TIFFIsTiled(tiff) != MagickFalse)
method=ReadTileMethod;
quantum_type=RGBQuantum;
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));
+ q->opacity=(Quantum) (QuantumRange-
+ ScaleCharToQuantum((unsigned char) TIFFGetA(*p)));
p--;
q--;
}
MagickInfo
*entry;
-
+
if (tiff_semaphore == (SemaphoreInfo *) NULL)
tiff_semaphore=AllocateSemaphoreInfo();
LockSemaphoreInfo(tiff_semaphore);
entry->raw=MagickTrue;
entry->endian_support=MagickTrue;
entry->adjoin=MagickFalse;
+ entry->format_type=ImplicitFormatType;
entry->seekable_stream=MagickTrue;
entry->thread_support=NoThreadSupport;
entry->description=ConstantString("Raw CCITT Group4");
MagickStatusType
flags;
+ uint32
+ tile_columns,
+ tile_rows;
+
assert(tiff_info != (TIFFInfo *) NULL);
(void) ResetMagickMemory(tiff_info,0,sizeof(*tiff_info));
option=GetImageOption(image_info,"tiff:tile-geometry");
flags=ParseAbsoluteGeometry(option,&tiff_info->tile_geometry);
if ((flags & HeightValue) == 0)
tiff_info->tile_geometry.height=tiff_info->tile_geometry.width;
- (void) TIFFSetField(tiff,TIFFTAG_TILEWIDTH,(uint32)
- tiff_info->tile_geometry.width);
- (void) TIFFSetField(tiff,TIFFTAG_TILELENGTH,(uint32)
- tiff_info->tile_geometry.height);
+ tile_columns=(uint32) tiff_info->tile_geometry.width;
+ tile_rows=(uint32) tiff_info->tile_geometry.height;
+ TIFFDefaultTileSize(tiff,&tile_columns,&tile_rows);
+ (void) TIFFSetField(tiff,TIFFTAG_TILEWIDTH,tile_columns);
+ (void) TIFFSetField(tiff,TIFFTAG_TILELENGTH,tile_rows);
+ tiff_info->tile_geometry.width=tile_columns;
+ tiff_info->tile_geometry.height=tile_rows;
tiff_info->scanlines=(unsigned char *) AcquireQuantumMemory((size_t)
- tiff_info->tile_geometry.height*TIFFScanlineSize(tiff),
- sizeof(*tiff_info->scanlines));
+ tile_rows*TIFFScanlineSize(tiff),sizeof(*tiff_info->scanlines));
tiff_info->pixels=(unsigned char *) AcquireQuantumMemory((size_t)
- TIFFTileSize(tiff),sizeof(*tiff_info->scanlines));
+ tile_rows*TIFFTileSize(tiff),sizeof(*tiff_info->scanlines));
if ((tiff_info->scanlines == (unsigned char *) NULL) ||
(tiff_info->pixels == (unsigned char *) NULL))
{
const char
*value;
+ (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
value=GetImageProperty(image,"tiff:hostcomputer");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_HOSTCOMPUTER,value);
value=GetImageProperty(image,"tiff:model");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,TIFFTAG_MODEL,value);
- (void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,
- GetMagickVersion((size_t *) NULL));
- (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
+ value=GetImageProperty(image,"tiff:software");
+ if (value != (const char *) NULL)
+ (void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,value);
value=GetImageProperty(image,"tiff:copyright");
if (value != (const char *) NULL)
(void) TIFFSetField(tiff,33432,value);
CompressionType
compression;
+ EndianType
+ endian_type;
+
ssize_t
y;
(void) MagickSetThreadValue(tiff_exception,&image->exception);
error_handler=TIFFSetErrorHandler((TIFFErrorHandler) TIFFErrors);
warning_handler=TIFFSetWarningHandler((TIFFErrorHandler) TIFFWarnings);
- switch (image_info->endian)
+ endian_type=UndefinedEndian;
+ option=GetImageOption(image_info,"tiff:endian");
+ if (option != (const char *) NULL)
+ {
+ if (LocaleNCompare(option,"msb",3) == 0)
+ endian_type=MSBEndian;
+ if (LocaleNCompare(option,"lsb",3) == 0)
+ endian_type=LSBEndian;;
+ }
+ switch (endian_type)
{
case LSBEndian: mode="wl"; break;
case MSBEndian: mode="wb"; break;
}
#if defined(TIFF_VERSION_BIG)
if (LocaleCompare(image_info->magick,"TIFF64") == 0)
- switch (image_info->endian)
+ switch (endian_type)
{
case LSBEndian: mode="wl8"; break;
case MSBEndian: mode="wb8"; break;
{
photometric=PHOTOMETRIC_YCBCR;
(void) TIFFSetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,1,1);
+ (void) SetImageStorageClass(image,DirectClass);
(void) SetImageDepth(image,8);
}
else
MagickFalse ? PHOTOMETRIC_MINISWHITE :
PHOTOMETRIC_MINISBLACK);
(void) TIFFSetField(tiff,TIFFTAG_SAMPLESPERPIXEL,1);
- if ((image_info->depth == 0) &&
+ if ((image_info->depth == 0) && (image->matte == MagickFalse) &&
(IsMonochromeImage(image,&image->exception) != MagickFalse))
{
status=SetQuantumDepth(image,quantum_info,1);
compress_tag=COMPRESSION_NONE;
endian=FILLORDER_MSB2LSB;
}
+ option=GetImageProperty(image,"tiff:fill-order");
+ if (option != (const char *) NULL)
+ {
+ if (LocaleNCompare(option,"msb",3) == 0)
+ endian=FILLORDER_MSB2LSB;
+ if (LocaleNCompare(option,"lsb",3) == 0)
+ endian=FILLORDER_LSB2MSB;
+ }
(void) TIFFSetField(tiff,TIFFTAG_COMPRESSION,compress_tag);
(void) TIFFSetField(tiff,TIFFTAG_FILLORDER,endian);
(void) TIFFSetField(tiff,TIFFTAG_BITSPERSAMPLE,quantum_info->depth);
flags=ParseGeometry(sampling_factor,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
- (void) TIFFSetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,(uint16)
- geometry_info.rho,(uint16) geometry_info.sigma);
+ if (image->colorspace == YCbCrColorspace)
+ (void) TIFFSetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,(uint16)
+ geometry_info.rho,(uint16) geometry_info.sigma);
}
}
if (bits_per_sample == 12)
default:
break;
}
- (void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);
+ option=GetImageOption(image_info,"tiff:tile-geometry");
+ if (option == (const char *) NULL)
+ (void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);
if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
{
unsigned short
break;
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
- image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
+ y,image->rows);
if (status == MagickFalse)
break;
}