% 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 %
}
code=0;
argv=StringToArgv(command,&argc);
+ if (argv == (char **) NULL)
+ return(MagickFalse);
status=(ghost_info->init_with_args)(interpreter,argc-1,argv+1);
if (status == 0)
status=(ghost_info->run_string)(interpreter,"systemdict /start get exec\n",
flags;
PointInfo
- delta;
+ delta,
+ resolution;
RectangleInfo
page;
hex_digits[256];
size_t
- length;
+ length,
+ priority;
ssize_t
count;
*/
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);
+ resolution=image->resolution;
+ page.width=(size_t) ceil((double) (page.width*resolution.x/delta.x)-0.5);
+ page.height=(size_t) ceil((double) (page.height*resolution.y/delta.y)-0.5);
/*
Determine page geometry from the Postscript 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;
- columns=0;
+ cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
+ (void) ResetMagickMemory(&hires_bounds,0,sizeof(hires_bounds));
+ priority=0;
rows=0;
extent=0;
spotcolor=0;
language_level=1;
- skip=MagickFalse;
- cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
pages=(~0UL);
+ skip=MagickFalse;
p=command;
for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
{
continue;
if (LocaleNCompare(PostscriptLevel,command,strlen(PostscriptLevel)) == 0)
{
- (void) SetImageProperty(image,"ps:Level",command+4);
+ (void) SetImageProperty(image,"ps:Level",command+4,exception);
if (GlobExpression(command,"*EPSF-*",MagickTrue) != MagickFalse)
pages=1;
}
datum=GetStringInfoDatum(profile);
datum[i]=(unsigned char) c;
}
- (void) SetImageProfile(image,"icc",profile);
+ (void) SetImageProfile(image,"icc",profile,exception);
profile=DestroyStringInfo(profile);
continue;
}
p=GetStringInfoDatum(profile);
for (i=0; i < (ssize_t) length; i++)
*p++=(unsigned char) ProfileInteger(image,hex_digits);
- (void) SetImageProfile(image,"8bim",profile);
+ (void) SetImageProfile(image,"8bim",profile,exception);
profile=DestroyStringInfo(profile);
continue;
}
break;
}
SetStringInfoLength(profile,i);
- (void) SetImageProfile(image,"xmp",profile);
+ (void) SetImageProfile(image,"xmp",profile,exception);
profile=DestroyStringInfo(profile);
continue;
}
(void) SubstituteString(&value,"(","");
(void) SubstituteString(&value,")","");
(void) StripString(value);
- (void) SetImageProperty(image,property,value);
+ (void) SetImageProperty(image,property,value,exception);
value=DestroyString(value);
continue;
}
+ if (image_info->page != (char *) NULL)
+ continue;
/*
Note region defined by bounding box.
*/
count=0;
+ i=0;
if (LocaleNCompare(BoundingBox,command,strlen(BoundingBox)) == 0)
- count=(ssize_t) sscanf(command,BoundingBox " %lf %lf %lf %lf",&bounds.x1,
- &bounds.y1,&bounds.x2,&bounds.y2);
+ {
+ count=(ssize_t) sscanf(command,BoundingBox " %lf %lf %lf %lf",
+ &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ i=2;
+ }
if (LocaleNCompare(DocumentMedia,command,strlen(DocumentMedia)) == 0)
- count=(ssize_t) sscanf(command,DocumentMedia " %*s %lf %lf",&bounds.x2,
- &bounds.y2)+2;
+ {
+ count=(ssize_t) sscanf(command,DocumentMedia " %lf %lf %lf %lf",
+ &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ i=1;
+ }
if (LocaleNCompare(HiResBoundingBox,command,strlen(HiResBoundingBox)) == 0)
- count=(ssize_t) sscanf(command,HiResBoundingBox " %lf %lf %lf %lf",
- &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ {
+ count=(ssize_t) sscanf(command,HiResBoundingBox " %lf %lf %lf %lf",
+ &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ i=3;
+ }
if (LocaleNCompare(PageBoundingBox,command,strlen(PageBoundingBox)) == 0)
- count=(ssize_t) sscanf(command,PageBoundingBox " %lf %lf %lf %lf",
- &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ {
+ count=(ssize_t) sscanf(command,PageBoundingBox " %lf %lf %lf %lf",
+ &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ i=1;
+ }
if (LocaleNCompare(PageMedia,command,strlen(PageMedia)) == 0)
- count=(ssize_t) sscanf(command,PageMedia " %*s %lf %lf",&bounds.x2,
- &bounds.y2)+2;
- 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 Postscript 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,"ps: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;
+ count=(ssize_t) sscanf(command,PageMedia " %lf %lf %lf %lf",
+ &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
+ i=1;
}
+ if ((count != 4) || (i < (ssize_t) priority))
+ continue;
+ 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;
+ priority=i;
}
+ if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) &&
+ (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
+ {
+ /*
+ Set Postscript render geometry.
+ */
+ (void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+.15g%+.15g",
+ hires_bounds.x2-hires_bounds.x1,hires_bounds.y2-hires_bounds.y1,
+ hires_bounds.x1,hires_bounds.y1);
+ (void) SetImageProperty(image,"ps:HiResBoundingBox",geometry,exception);
+ page.width=(size_t) ceil((double) ((hires_bounds.x2-hires_bounds.x1)*
+ resolution.x/delta.x)-0.5);
+ page.height=(size_t) ceil((double) ((hires_bounds.y2-hires_bounds.y1)*
+ resolution.y/delta.y)-0.5);
+ }
(void) CloseBlob(image);
- if (IsRGBColorspace(image_info->colorspace) != MagickFalse)
+ if (IssRGBCompatibleColorspace(image_info->colorspace) != MagickFalse)
cmyk=MagickFalse;
/*
Create Ghostscript control file.
file=AcquireUniqueFileResource(postscript_filename);
if (file == -1)
{
- ThrowFileException(&image->exception,FileOpenError,"UnableToOpenFile",
+ ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
image_info->filename);
image=DestroyImageList(image);
return((Image *) NULL);
return((Image *) NULL);
}
*options='\0';
- if ((page.width == 0) || (page.height == 0))
- (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
- 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);
- 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(density,MaxTextExtent,"%gx%g",resolution.x,
+ resolution.y);
(void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
page.width,(double) page.height);
read_info=CloneImageInfo(image_info);
if (read_info->scenes != (char *) NULL)
*read_info->scenes='\0';
}
- option=GetImageOption(image_info,"ps:use-cropbox");
- if ((option != (const char *) NULL) && (IsMagickTrue(option) != MagickFalse))
+ option=GetImageOption(image_info,"eps:use-cropbox");
+ if ((*image_info->magick == 'E') && ((option == (const char *) NULL) ||
+ (IsStringTrue(option) != MagickFalse)))
(void) ConcatenateMagickString(options,"-dEPSCrop ",MaxTextExtent);
(void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
(void) AcquireUniqueFilename(filename);
- (void) ConcatenateMagickString(filename,"-%08d",MaxTextExtent);
+ (void) ConcatenateMagickString(filename,"%d",MaxTextExtent);
(void) FormatLocaleString(command,MaxTextExtent,
GetDelegateCommands(delegate_info),
read_info->antialias != MagickFalse ? 4 : 1,
postscript_filename,input_filename);
status=InvokePostscriptDelegate(read_info->verbose,command,exception);
(void) InterpretImageFilename(image_info,image,filename,1,
- read_info->filename);
+ read_info->filename,exception);
if ((status == MagickFalse) ||
(IsPostscriptRendered(read_info->filename) == MagickFalse))
{
for (i=1; ; i++)
{
(void) InterpretImageFilename(image_info,image,filename,(int) i,
- read_info->filename);
+ read_info->filename,exception);
if (IsPostscriptRendered(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 (IsPostscriptRendered(read_info->filename) == MagickFalse)
break;
+ read_info->blob=NULL;
+ read_info->length=0;
next=ReadImage(read_info,exception);
(void) RelinquishUniqueFileResource(read_info->filename);
if (next == (Image *) NULL)
entry->adjoin=MagickFalse;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString(
"Encapsulated PostScript Interchange format");
entry->module=ConstantString("PS");
entry->adjoin=MagickFalse;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("Encapsulated PostScript");
entry->module=ConstantString("PS");
(void) RegisterMagickInfo(entry);
entry->adjoin=MagickFalse;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString(
"Encapsulated PostScript Interchange format");
entry->module=ConstantString("PS");
entry->module=ConstantString("PS");
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickTrue;
- entry->thread_support=EncoderThreadSupport;
entry->description=ConstantString("PostScript");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
{
#define WriteRunlengthPacket(image,pixel,length,p) \
{ \
- if ((image->matte != MagickFalse) && \
+ if ((image->alpha_trait == BlendPixelTrait) && \
(GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)) \
{ \
q=PopHexPixel(hex_digits,0xff,q); \
" currentfile buffer readline pop",
" token pop /compression exch def pop",
" class 0 gt { PseudoClassImage } { DirectClassImage } ifelse",
+ " grestore",
(char *) NULL
};
MagickStatusType
flags;
- PixelPacket
+ PixelInfo
pixel;
PointInfo
/*
Scale relative to dots-per-inch.
*/
- if ((IsRGBColorspace(image->colorspace) == MagickFalse) &&
- (image->colorspace != CMYKColorspace))
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
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);
if (page == 1)
(void) WriteBlobByte(image,GetStringInfoDatum(profile)[i]);
(void) WriteBlobString(image,"\n%end_xml_packet\n%end_xml_code\n");
}
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
(void) WriteBlobString(image,
"%%DocumentNeededResources: font Times-Roman\n");
(void) FormatLocaleString(buffer,MaxTextExtent,"%s\n",*s);
(void) WriteBlobString(image,buffer);
}
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
for (j=(ssize_t) MultilineCensus(value)-1; j >= 0; j--)
{
bounds.x2=(double) geometry.x+geometry.width-1;
if ((double) (geometry.y+(geometry.height+text_size)-1) > bounds.y2)
bounds.y2=(double) geometry.y+(geometry.height+text_size)-1;
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
(void) WriteBlobString(image,"%%%%PageResources: font Times-Roman\n");
if (LocaleCompare(image_info->magick,"PS") != 0)
(double) geometry.x,(double) geometry.y,scale.x,scale.y,pointsize);
(void) WriteBlobString(image,buffer);
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 (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
y,image->rows);
if (status == MagickFalse)
break;
}
else
if ((image->storage_class == DirectClass) ||
- (image->colors > 256) || (image->matte != MagickFalse))
+ (image->colors > 256) || (image->alpha_trait == BlendPixelTrait))
{
/*
Dump DirectClass image.
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
- GetPixelPacket(image,p,&pixel);
+ GetPixelInfoPixel(image,p,&pixel);
length=255;
for (x=0; x < (ssize_t) image->columns; x++)
{
}
length=0;
}
- GetPixelPacket(image,p,&pixel);
+ GetPixelInfoPixel(image,p,&pixel);
p+=GetPixelChannels(image);
}
WriteRunlengthPacket(image,pixel,length,p);
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- if ((image->matte != MagickFalse) &&
+ if ((image->alpha_trait == BlendPixelTrait) &&
(GetPixelAlpha(image,p) == (Quantum) TransparentAlpha))
{
q=PopHexPixel(hex_digits,0xff,q);
{
(void) FormatLocaleString(buffer,MaxTextExtent,
"%%%%BoundingBox: %.20g %.20g %.20g %.20g\n",ceil(bounds.x1-0.5),
- ceil(bounds.y1-0.5),floor(bounds.x2+0.5),floor(bounds.y2+0.5));
+ ceil(bounds.y1-0.5),floor(bounds.x2-0.5),floor(bounds.y2-0.5));
(void) WriteBlobString(image,buffer);
(void) FormatLocaleString(buffer,MaxTextExtent,
- "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,bounds.y1,
- bounds.x2,bounds.y2);
+ "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,bounds.y1,bounds.x2,
+ bounds.y2);
(void) WriteBlobString(image,buffer);
}
(void) WriteBlobString(image,"%%EOF\n");