c,
file;
- LinkedListInfo
- *profiles;
-
MagickBooleanType
cmyk,
fitPage,
(void) ResetMagickMemory(command,0,sizeof(command));
cmyk=image_info->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
(void) ResetMagickMemory(&hires_bounds,0,sizeof(hires_bounds));
- profiles=(LinkedListInfo *) NULL;
columns=0;
rows=0;
priority=0;
(void) sscanf(command,Pages " %lu",&pages);
if (LocaleNCompare(ImageData,command,strlen(ImageData)) == 0)
(void) sscanf(command,ImageData " %lu %lu",&columns,&rows);
- if (LocaleNCompare(ICCProfile,command,strlen(ICCProfile)) == 0)
- {
- unsigned char
- *datum;
-
- /*
- Read ICC profile.
- */
- profile=AcquireStringInfo(MagickPathExtent);
- datum=GetStringInfoDatum(profile);
- for (i=0; (c=ProfileInteger(image,hex_digits)) != EOF; i++)
- {
- if (i >= (ssize_t) GetStringInfoLength(profile))
- {
- SetStringInfoLength(profile,(size_t) i << 1);
- datum=GetStringInfoDatum(profile);
- }
- datum[i]=(unsigned char) c;
- }
- SetStringInfoLength(profile,(size_t) i+1);
- if (profiles == (LinkedListInfo *) NULL)
- profiles=NewLinkedList(0);
- (void) AppendValueToLinkedList(profiles,AcquireString("icc"));
- profile=DestroyStringInfo(profile);
- continue;
- }
- if (LocaleNCompare(PhotoshopProfile,command,strlen(PhotoshopProfile)) == 0)
- {
- unsigned char
- *q;
-
- /*
- Read Photoshop profile.
- */
- count=(ssize_t) sscanf(command,PhotoshopProfile " %lu",&extent);
- if (count != 1)
- continue;
- length=extent;
- if ((MagickSizeType) length > GetBlobSize(image))
- ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
- profile=BlobToStringInfo((const void *) NULL,length);
- if (profile != (StringInfo *) NULL)
- {
- q=GetStringInfoDatum(profile);
- for (i=0; i < (ssize_t) length; i++)
- *q++=(unsigned char) ProfileInteger(image,hex_digits);
- if (profiles == (LinkedListInfo *) NULL)
- profiles=NewLinkedList(0);
- (void) AppendValueToLinkedList(profiles,AcquireString("8bim"));
- profile=DestroyStringInfo(profile);
- }
- continue;
- }
- if (LocaleNCompare(BeginXMPPacket,command,strlen(BeginXMPPacket)) == 0)
- {
- /*
- Read XMP profile.
- */
- p=command;
- profile=StringToStringInfo(command);
- for (i=(ssize_t) GetStringInfoLength(profile)-1; c != EOF; i++)
- {
- SetStringInfoLength(profile,(size_t) i+1);
- c=ReadBlobByte(image);
- if (c == EOF)
- continue;
- GetStringInfoDatum(profile)[i]=(unsigned char) c;
- *p++=(char) c;
- if ((strchr("\n\r%",c) == (char *) NULL) &&
- ((size_t) (p-command) < (MagickPathExtent-1)))
- continue;
- *p='\0';
- p=command;
- if (LocaleNCompare(EndXMPPacket,command,strlen(EndXMPPacket)) == 0)
- break;
- }
- SetStringInfoLength(profile,(size_t) i);
- if (EOFBlob(image) == MagickFalse)
- {
- if (profiles == (LinkedListInfo *) NULL)
- profiles=NewLinkedList(0);
- (void) AppendValueToLinkedList(profiles,AcquireString("xmp"));
- }
- profile=DestroyStringInfo(profile);
- continue;
- }
/*
Is this a CMYK document?
*/
if (i == (ssize_t) priority)
continue;
hires_bounds=bounds;
- priority=i;
+ priority=(size_t) i;
}
if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) &&
(fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
fitPage=MagickFalse;
option=GetImageOption(image_info,"eps:fit-page");
if (option != (char *) NULL)
- {
- char
- *page_geometry;
+ {
+ char
+ *page_geometry;
- page_geometry=GetPageGeometry(option);
- flags=ParseMetaGeometry(page_geometry,&page.x,&page.y,&page.width,
- &page.height);
- if (flags == NoValue)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
- "InvalidGeometry","`%s'",option);
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
- image=DestroyImage(image);
- return((Image *) NULL);
- }
- 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);
- page_geometry=DestroyString(page_geometry);
- fitPage=MagickTrue;
- }
- (void) CloseBlob(image);
+ page_geometry=GetPageGeometry(option);
+ flags=ParseMetaGeometry(page_geometry,&page.x,&page.y,&page.width,
+ &page.height);
+ if (flags == NoValue)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+ "InvalidGeometry","`%s'",option);
+ image=DestroyImage(image);
+ return((Image *) NULL);
+ }
+ 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);
+ page_geometry=DestroyString(page_geometry);
+ fitPage=MagickTrue;
+ }
if (IssRGBCompatibleColorspace(image_info->colorspace) != MagickFalse)
cmyk=MagickFalse;
/*
{
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
image_info->filename);
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
image=DestroyImageList(image);
return((Image *) NULL);
}
if (delegate_info == (const DelegateInfo *) NULL)
{
(void) RelinquishUniqueFileResource(postscript_filename);
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
image=DestroyImageList(image);
return((Image *) NULL);
}
if (*message != '\0')
(void) ThrowMagickException(exception,GetMagickModule(),
DelegateError,"PostscriptDelegateFailed","`%s'",message);
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
image=DestroyImageList(image);
return((Image *) NULL);
}
postscript_image=cmyk_image;
}
}
+ (void) SeekBlob(image,0,SEEK_SET);
+ for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
+ {
+ /*
+ Note document structuring comments.
+ */
+ *p++=(char) c;
+ if ((strchr("\n\r%",c) == (char *) NULL) &&
+ ((size_t) (p-command) < (MagickPathExtent-1)))
+ continue;
+ *p='\0';
+ p=command;
+ /*
+ Skip %%BeginDocument thru %%EndDocument.
+ */
+ if (LocaleNCompare(BeginDocument,command,strlen(BeginDocument)) == 0)
+ skip=MagickTrue;
+ if (LocaleNCompare(EndDocument,command,strlen(EndDocument)) == 0)
+ skip=MagickFalse;
+ if (skip != MagickFalse)
+ continue;
+ if (LocaleNCompare(ICCProfile,command,strlen(ICCProfile)) == 0)
+ {
+ unsigned char
+ *datum;
+
+ /*
+ Read ICC profile.
+ */
+ profile=AcquireStringInfo(MagickPathExtent);
+ datum=GetStringInfoDatum(profile);
+ for (i=0; (c=ProfileInteger(image,hex_digits)) != EOF; i++)
+ {
+ if (i >= (ssize_t) GetStringInfoLength(profile))
+ {
+ SetStringInfoLength(profile,(size_t) i << 1);
+ datum=GetStringInfoDatum(profile);
+ }
+ datum[i]=(unsigned char) c;
+ }
+ SetStringInfoLength(profile,(size_t) i+1);
+ (void) SetImageProfile(image,"icc",profile,exception);
+ profile=DestroyStringInfo(profile);
+ continue;
+ }
+ if (LocaleNCompare(PhotoshopProfile,command,strlen(PhotoshopProfile)) == 0)
+ {
+ unsigned char
+ *q;
+
+ /*
+ Read Photoshop profile.
+ */
+ count=(ssize_t) sscanf(command,PhotoshopProfile " %lu",&extent);
+ if (count != 1)
+ continue;
+ length=extent;
+ if ((MagickSizeType) length > GetBlobSize(image))
+ ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
+ profile=BlobToStringInfo((const void *) NULL,length);
+ if (profile != (StringInfo *) NULL)
+ {
+ q=GetStringInfoDatum(profile);
+ for (i=0; i < (ssize_t) length; i++)
+ *q++=(unsigned char) ProfileInteger(image,hex_digits);
+ (void) SetImageProfile(image,"8bim",profile,exception);
+ profile=DestroyStringInfo(profile);
+ }
+ continue;
+ }
+ if (LocaleNCompare(BeginXMPPacket,command,strlen(BeginXMPPacket)) == 0)
+ {
+ /*
+ Read XMP profile.
+ */
+ p=command;
+ profile=StringToStringInfo(command);
+ for (i=(ssize_t) GetStringInfoLength(profile)-1; c != EOF; i++)
+ {
+ SetStringInfoLength(profile,(size_t) (i+1));
+ c=ReadBlobByte(image);
+ GetStringInfoDatum(profile)[i]=(unsigned char) c;
+ *p++=(char) c;
+ if ((strchr("\n\r%",c) == (char *) NULL) &&
+ ((size_t) (p-command) < (MagickPathExtent-1)))
+ continue;
+ *p='\0';
+ p=command;
+ if (LocaleNCompare(EndXMPPacket,command,strlen(EndXMPPacket)) == 0)
+ break;
+ }
+ SetStringInfoLength(profile,(size_t) i);
+ (void) SetImageProfile(image,"xmp",profile,exception);
+ profile=DestroyStringInfo(profile);
+ continue;
+ }
+ }
+ (void) CloseBlob(image);
if (image_info->number_scenes != 0)
{
Image
PrependImageToList(&postscript_image,clone_image);
}
}
- if (profiles != (LinkedListInfo *) NULL)
- {
- const char
- *name;
-
- const StringInfo
- *profile;
-
- /*
- Read image profiles.
- */
- ResetLinkedListIterator(profiles);
- name=(const char *) GetNextValueInLinkedList(profiles);
- while (name != (const char *) NULL)
- {
- profile=GetImageProfile(image,name);
- if (profile != (StringInfo *) NULL)
- {
- register unsigned char
- *p;
-
- p=GetStringInfoDatum(profile);
- count=ReadBlob(image,GetStringInfoLength(profile),p);
- (void) count;
- }
- name=(const char *) GetNextValueInLinkedList(profiles);
- }
- profiles=DestroyLinkedList(profiles,RelinquishMagickMemory);
- }
do
{
(void) CopyMagickString(postscript_image->filename,filename,