]> granicus.if.org Git - imagemagick/blobdiff - coders/pdf.c
(no commit message)
[imagemagick] / coders / pdf.c
index a6766911f73a55cc19678b5394d0ba6eb8bb35d1..e54342ade73ae7b95374c2db66e3642645fc7376 100644 (file)
@@ -17,7 +17,7 @@
 %                                 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  %
@@ -73,6 +73,7 @@
 #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"
@@ -424,14 +425,8 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     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));
@@ -537,9 +532,13 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
     if (count != 4)
       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;
   }
-  if ((hires_bounds.x2 != 0.0) && (hires_bounds.y2 != 0.0))
+  if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) && 
+      (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
     {
       /*
         Set PDF render geometry.
@@ -563,7 +562,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       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.
@@ -598,8 +597,9 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   *options='\0';
   (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",image->resolution.x,
     image->resolution.y);
-  (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
-     page.width,(double) page.height);
+  if (image_info->page != (char *) NULL)
+    (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
+       page.width,(double) page.height);
   if (cmyk != MagickFalse)
     (void) ConcatenateMagickString(options,"-dUseCIEColor ",MaxTextExtent);
   if (cropbox != MagickFalse)
@@ -1253,8 +1253,8 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image,
     }
     if (compression == JPEG2000Compression)
       {
-        if (IsRGBColorspace(image->colorspace) == MagickFalse)
-          (void) TransformImageColorspace(image,RGBColorspace,exception);
+        if (IssRGBColorspace(image->colorspace) == MagickFalse)
+          (void) TransformImageColorspace(image,sRGBColorspace,exception);
       }
     /*
       Scale relative to dots-per-inch.