% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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 "MagickCore/static.h"
#include "MagickCore/string_.h"
#include "MagickCore/module.h"
+#include "MagickCore/token.h"
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
#include "MagickCore/module.h"
/*
Open image file.
*/
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
- if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
+ if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
{
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
- image->y_resolution=image->x_resolution;
+ image->resolution.y=image->resolution.x;
}
+ if (image_info->density != (char *) NULL)
+ {
+ flags=ParseGeometry(image_info->density,&geometry_info);
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
+ if ((flags & SigmaValue) == 0)
+ image->resolution.y=image->resolution.x;
+ }
+ (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
+ if (image_info->page != (char *) NULL)
+ (void) ParseAbsoluteGeometry(image_info->page,&page);
+ page.width=(size_t) ceil((double) (page.width*image->resolution.x/delta.x)-
+ 0.5);
+ page.height=(size_t) ceil((double) (page.height*image->resolution.y/delta.y)-
+ 0.5);
/*
Determine page geometry from the PDF media box.
*/
cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
- cropbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-cropbox");
- if (option != (const char *) NULL)
- cropbox=IsMagickTrue(option);
- trimbox=MagickFalse;
- option=GetImageOption(image_info,"pdf:use-trimbox");
- if (option != (const char *) NULL)
- trimbox=IsMagickTrue(option);
+ cropbox=IsStringTrue(GetImageOption(image_info,"pdf:use-cropbox"));
+ trimbox=IsStringTrue(GetImageOption(image_info,"pdf:use-trimbox"));
count=0;
spotcolor=0;
(void) ResetMagickMemory(&bounding_box,0,sizeof(bounding_box));
(void) ResetMagickMemory(&bounds,0,sizeof(bounds));
(void) ResetMagickMemory(&hires_bounds,0,sizeof(hires_bounds));
- (void) ResetMagickMemory(&page,0,sizeof(page));
(void) ResetMagickMemory(command,0,sizeof(command));
- hires_bounds.x2=0.0;
- hires_bounds.y2=0.0;
angle=0.0;
p=command;
for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
name[i]='\0';
value=AcquireString(name);
(void) SubstituteString(&value,"#20"," ");
- (void) SetImageProperty(image,property,value);
+ (void) SetImageProperty(image,property,value,exception);
value=DestroyString(value);
continue;
}
if (LocaleNCompare(PDFVersion,command,strlen(PDFVersion)) == 0)
- (void) SetImageProperty(image,"pdf:Version",command);
+ (void) SetImageProperty(image,"pdf:Version",command,exception);
+ if (image_info->page != (char *) NULL)
+ continue;
count=0;
if (cropbox != MagickFalse)
{
}
if (count != 4)
continue;
- if (((bounds.x2 > hires_bounds.x2) && (bounds.y2 > hires_bounds.y2)) ||
- ((hires_bounds.x2 == 0.0) && (hires_bounds.y2 == 0.0)))
- {
- /*
- Set PDF render geometry.
- */
- (void) FormatLocaleString(geometry,MaxTextExtent,
- "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
- bounds.x1,bounds.y1);
- (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry);
- page.width=(size_t) floor(bounds.x2-bounds.x1+0.5);
- page.height=(size_t) floor(bounds.y2-bounds.y1+0.5);
- hires_bounds=bounds;
- }
+ if ((fabs(bounds.x2-bounds.x1) <= fabs(hires_bounds.x2-hires_bounds.x1)) ||
+ (fabs(bounds.y2-bounds.y1) <= fabs(hires_bounds.y2-hires_bounds.y1)))
+ continue;
+ hires_bounds=bounds;
}
+ if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) &&
+ (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
+ {
+ /*
+ Set PDF render geometry.
+ */
+ (void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+.15g%+.15g",
+ hires_bounds.x2-bounds.x1,hires_bounds.y2-hires_bounds.y1,
+ hires_bounds.x1,hires_bounds.y1);
+ (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry,exception);
+ page.width=(size_t) ceil((double) ((hires_bounds.x2-hires_bounds.x1)*
+ image->resolution.x/delta.x)-0.5);
+ page.height=(size_t) ceil((double) ((hires_bounds.y2-hires_bounds.y1)*
+ image->resolution.y/delta.y)-0.5);
+ }
(void) CloseBlob(image);
if ((fabs(angle) == 90.0) || (fabs(angle) == 270.0))
{
page.width=page.height;
page.height=swap;
}
- if (IsRGBColorspace(image_info->colorspace) != MagickFalse)
+ if (IssRGBColorspace(image_info->colorspace) != MagickFalse)
cmyk=MagickFalse;
/*
Create Ghostscript control file.
return((Image *) NULL);
}
*options='\0';
- if (image_info->density != (char *) NULL)
- {
- flags=ParseGeometry(image_info->density,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
- if ((flags & SigmaValue) == 0)
- image->y_resolution=image->x_resolution;
- }
- (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",image->x_resolution,
- image->y_resolution);
+ (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",image->resolution.x,
+ image->resolution.y);
if (image_info->page != (char *) NULL)
- {
- (void) ParseAbsoluteGeometry(image_info->page,&page);
- page.width=(size_t) floor((double) (page.width*image->x_resolution/
- delta.x)+0.5);
- page.height=(size_t) floor((double) (page.height*image->y_resolution/
- delta.y)+0.5);
- (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
- page.width,(double) page.height);
- }
+ (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
+ page.width,(double) page.height);
if (cmyk != MagickFalse)
(void) ConcatenateMagickString(options,"-dUseCIEColor ",MaxTextExtent);
if (cropbox != MagickFalse)
if (read_info->scenes != (char *) NULL)
*read_info->scenes='\0';
}
- if (read_info->authenticate != (char *) NULL)
+ option=GetImageOption(read_info,"authenticate");
+ if (option != (const char *) NULL)
(void) FormatLocaleString(options+strlen(options),MaxTextExtent,
- " -sPDFPassword=%s",read_info->authenticate);
+ " -sPCLPassword=%s",option);
(void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
(void) AcquireUniqueFilename(filename);
(void) ConcatenateMagickString(filename,"-%08d",MaxTextExtent);
for (i=1; ; i++)
{
(void) InterpretImageFilename(image_info,image,filename,(int) i,
- read_info->filename);
+ read_info->filename,exception);
if (IsPDFRendered(read_info->filename) == MagickFalse)
break;
(void) RelinquishUniqueFileResource(read_info->filename);
for (i=1; ; i++)
{
(void) InterpretImageFilename(image_info,image,filename,(int) i,
- read_info->filename);
+ read_info->filename,exception);
if (IsPDFRendered(read_info->filename) == MagickFalse)
break;
next=ReadImage(read_info,exception);
}
static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
- Image *image,Image *inject_image)
+ Image *image,Image *inject_image,ExceptionInfo *exception)
{
Image
*group4_image;
write_info=CloneImageInfo(image_info);
(void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent);
(void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent);
- group4_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception);
+ group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
if (group4_image == (Image *) NULL)
return(MagickFalse);
group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
- &image->exception);
+ exception);
group4_image=DestroyImage(group4_image);
if (group4 == (unsigned char *) NULL)
return(MagickFalse);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) WriteBlobString(image,"<<\n");
(void) WriteBlobString(image,"/Subtype /XML\n");
*modify_date='\0';
- value=GetImageProperty(image,"date:modify");
+ value=GetImageProperty(image,"date:modify",exception);
if (value != (const char *) NULL)
(void) CopyMagickString(modify_date,value,MaxTextExtent);
*create_date='\0';
- value=GetImageProperty(image,"date:create");
+ value=GetImageProperty(image,"date:create",exception);
if (value != (const char *) NULL)
(void) CopyMagickString(create_date,value,MaxTextExtent);
(void) FormatMagickTime(time((time_t *) NULL),MaxTextExtent,timestamp);
}
if (compression == JPEG2000Compression)
{
- if (IsRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
}
/*
Scale relative to dots-per-inch.
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
- resolution.x=image->x_resolution;
- resolution.y=image->y_resolution;
+ resolution.x=image->resolution.x;
+ resolution.y=image->resolution.y;
if ((resolution.x == 0.0) || (resolution.y == 0.0))
{
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
if (image_info->pointsize != 0.0)
pointsize=image_info->pointsize;
text_size=0;
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
text_size=(size_t) (MultilineCensus(value)*pointsize+12);
(void) text_size;
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/Resources <<\n");
labels=(char **) NULL;
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
labels=StringToList(value);
if (labels != (char **) NULL)
{
if (LocaleCompare(CCITTParam,"0") == 0)
{
- (void) HuffmanEncodeImage(image_info,image,image);
+ (void) HuffmanEncodeImage(image_info,image,image,exception);
break;
}
- (void) Huffman2DEncodeImage(image_info,image,image);
+ (void) Huffman2DEncodeImage(image_info,image,image,exception);
break;
}
case JPEGCompression:
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
{
if (LocaleCompare(CCITTParam,"0") == 0)
{
- (void) HuffmanEncodeImage(image_info,image,tile_image);
+ (void) HuffmanEncodeImage(image_info,image,tile_image,
+ exception);
break;
}
- (void) Huffman2DEncodeImage(image_info,image,tile_image);
+ (void) Huffman2DEncodeImage(image_info,image,tile_image,exception);
break;
}
case JPEGCompression:
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{
}
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if (compression == ZipCompression)
- status=ZLIBEncodeImage(image,length,pixels);
+ status=ZLIBEncodeImage(image,length,pixels,exception);
else
#endif
if (compression == LZWCompression)
- status=LZWEncodeImage(image,length,pixels);
+ status=LZWEncodeImage(image,length,pixels,exception);
else
- status=PackbitsEncodeImage(image,length,pixels);
+ status=PackbitsEncodeImage(image,length,pixels,exception);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (status == MagickFalse)
{