]> granicus.if.org Git - imagemagick/commitdiff
Added eps:fit-page to Phostscript reader.
authordirk <dirk@git.imagemagick.org>
Sat, 25 Oct 2014 06:32:14 +0000 (06:32 +0000)
committerdirk <dirk@git.imagemagick.org>
Sat, 25 Oct 2014 06:32:14 +0000 (06:32 +0000)
coders/ps.c

index 4e658b3c5b08da9bb642b2fd1e0adf615ac24889..28d6f17250cf8cc63d3f460f000afa6f70c46555 100644 (file)
@@ -436,6 +436,7 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   MagickBooleanType
     cmyk,
+    fitPage,
     skip,
     status;
 
@@ -780,6 +781,32 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       page.height=(size_t) ceil((double) ((hires_bounds.y2-hires_bounds.y1)*
         resolution.y/delta.y)-0.5);
     }
+  fitPage=MagickFalse;
+  option=GetImageOption(image_info,"eps:fit-page");
+  if (option != (char *) NULL)
+  {
+    char
+      *geometry;
+
+    MagickStatusType
+      flags;
+
+    geometry=GetPageGeometry(option);
+    flags=ParseMetaGeometry(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);
+    geometry=DestroyString(geometry);
+    fitPage=MagickTrue;
+  }
   (void) CloseBlob(image);
   if (IssRGBCompatibleColorspace(image_info->colorspace) != MagickFalse)
     cmyk=MagickFalse;
@@ -845,10 +872,15 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (read_info->scenes != (char *) NULL)
         *read_info->scenes='\0';
     }
-  option=GetImageOption(image_info,"eps:use-cropbox");
-  if ((*image_info->magick == 'E') && ((option == (const char *) NULL) || 
-      (IsStringTrue(option) != MagickFalse)))
-    (void) ConcatenateMagickString(options,"-dEPSCrop ",MaxTextExtent);
+  if (*image_info->magick == 'E')
+    {
+      option=GetImageOption(image_info,"eps:use-cropbox");
+      if ((option == (const char *) NULL) ||
+          (IsStringTrue(option) != MagickFalse))
+        (void) ConcatenateMagickString(options,"-dEPSCrop ",MaxTextExtent);
+      if (fitPage != MagickFalse)
+        (void) ConcatenateMagickString(options,"-dEPSFitPage ",MaxTextExtent);
+    }
   (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
   (void) AcquireUniqueFilename(filename);
   (void) RelinquishUniqueFileResource(filename);