Page 1 of 1

-direction option on convert does not affet to create pdf file

Posted: 2016-02-16T15:38:22-07:00
by daiki.matsuda
-direction option on convert does not affet to create pdf file.
So, I attach the patch.

Re: -direction option on convert does not affet to create pdf file

Posted: 2016-02-16T15:40:19-07:00
by daiki.matsuda
Sorry, I do not understand how to attach the patch file.
So, directly pasting.

Code: Select all

###
--- ImageMagick-6.7.2-7/wand/convert.c  2016-02-15 09:52:26.852190748 +0900
+++ ImageMagick-6.7.2-7/wand/convert.c.new      2016-02-15 09:52:22.328153562 +0900
@@ -1214,9 +1214,12 @@ WandExport MagickBooleanType ConvertImag
               ThrowConvertException(OptionError,"MissingArgument",option);
             direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
               argv[i]);
-            if (direction < 0)
+            if (direction < 0) {
               ThrowConvertException(OptionError,"UnrecognizedDirectionType",
                 argv[i]);
+            }
+            else
+              image_info->direction = direction;
             break;
           }
         if (LocaleCompare("display",option+1) == 0)
--- ImageMagick-6.7.2-7/magick/image.h  2016-02-15 09:51:49.988889899 +0900
+++ ImageMagick-6.7.2-7/magick/image.h.new      2016-02-15 09:51:44.195842564 +0900
@@ -483,6 +483,9 @@ struct _ImageInfo
 
   MagickBooleanType
     synchronize;
+
+  ssize_t
+    direction;
 };
 
 extern MagickExport ExceptionType
--- ImageMagick-6.7.2-7/coders/pdf.c    2016-02-15 09:52:15.741099877 +0900
+++ ImageMagick-6.7.2-7/coders/pdf.c.new        2016-02-15 09:52:07.299031353 +0900
@@ -1100,7 +1100,10 @@ static MagickBooleanType WritePDFImage(c
         (double) object+2);
     }
   (void) WriteBlobString(image,buffer);
-  (void) WriteBlobString(image,"/Type /Catalog\n");
+  (void) WriteBlobString(image,"/Type /Catalog");
+  if (image_info->direction == RightToLeftDirection)
+    (void) WriteBlobString(image,"/ViewerPreferences<</PageDirection/R2L>>");
+  (void) WriteBlobString(image,"\n");
   (void) WriteBlobString(image,">>\n");
   (void) WriteBlobString(image,"endobj\n");
   if (LocaleCompare(image_info->magick,"PDFA") == 0)
--- ImageMagick-6.7.2-7/magick/image.c  2016-02-16 07:52:28.151036617 +0900
+++ ImageMagick-6.7.2-7/magick/image.c.new      2016-02-16 07:52:21.503977804 +0900
@@ -976,6 +976,7 @@ MagickExport ImageInfo *CloneImageInfo(c
   clone_info->channel=image_info->channel;
   clone_info->debug=IsEventLogging();
   clone_info->signature=image_info->signature;
+  clone_info->direction=image_info->direction;
   return(clone_info);
 }

Re: -direction option on convert does not affet to create pdf file

Posted: 2016-02-17T11:15:41-07:00
by magick
We added your patch, except its activated with this option: -define pdf:page-direction=right-to-left. Thanks.