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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
daiki.matsuda
Posts: 2
Joined: 2016-02-16T15:35:30-07:00
Authentication code: 1151

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

Post by daiki.matsuda »

-direction option on convert does not affet to create pdf file.
So, I attach the patch.
daiki.matsuda
Posts: 2
Joined: 2016-02-16T15:35:30-07:00
Authentication code: 1151

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

Post 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);
 }
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

We added your patch, except its activated with this option: -define pdf:page-direction=right-to-left. Thanks.
Post Reply