GraphicsMagick: Add -auto-orient support to 'compare'

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.41969.1647026815.1607.graphicsmagick-commit@lists.sourceforge.net>
changeset a0a3bc91a1fa in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=a0a3bc91a1fa
summary: Add -auto-orient support to 'compare'

diffstat:

 ChangeLog                              |   6 ++++
 VisualMagick/installer/inc/version.isx |   4 +-
 doc/options.imdoc                      |   2 +-
 magick/command.c                       |  42 +++++++++++++++++++++++++++++++++-
 magick/version.h                       |   4 +-
 utilities/gm.1                         |   5 +++-
 www/Changelog.html                     |   5 ++++
 www/compare.html                       |  11 ++++++++
 www/gm.html                            |  11 ++++++++
 9 files changed, 83 insertions(+), 7 deletions(-)

diffs (211 lines):

diff -r 28b759ad4ccd -r a0a3bc91a1fa ChangeLog
--- a/ChangeLog	Wed Mar 09 16:31:14 2022 -0600
+++ b/ChangeLog	Fri Mar 11 13:26:39 2022 -0600
@@ -1,3 +1,9 @@
+2022-03-11  Bob Friesenhahn  <[email protected]>
+
+        * magick/command.c (CompareImageCommand): Add -auto-orient support
+        to 'compare'.  This tries to assure that the two images are right
+        side up before comparing.
+
 2022-03-05  Bob Friesenhahn  <[email protected]>
 
         * coders/jxl.c (WriteJXLImage): Work to update JXL writer code to
diff -r 28b759ad4ccd -r a0a3bc91a1fa VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Wed Mar 09 16:31:14 2022 -0600
+++ b/VisualMagick/installer/inc/version.isx	Fri Mar 11 13:26:39 2022 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020220305"
-#define public MagickPackageReleaseDate "snapshot-20220305"
+#define public MagickPackageVersionAddendum ".020220311"
+#define public MagickPackageReleaseDate "snapshot-20220311"
diff -r 28b759ad4ccd -r a0a3bc91a1fa doc/options.imdoc
--- a/doc/options.imdoc	Wed Mar 09 16:31:14 2022 -0600
+++ b/doc/options.imdoc	Fri Mar 11 13:26:39 2022 -0600
@@ -180,7 +180,7 @@
 
 <!-- ------------ -auto-orient ------------------------------------- -->
 
-<utils apps=convert,mogrify>
+<utils apps=compare,convert,mogrify>
 <dopt>-auto-orient</opt>
 
 <abs>orient (rotate) image so it is upright</abs>
diff -r 28b759ad4ccd -r a0a3bc91a1fa magick/command.c
--- a/magick/command.c	Wed Mar 09 16:31:14 2022 -0600
+++ b/magick/command.c	Fri Mar 11 13:26:39 2022 -0600
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2020 GraphicsMagick Group
+% Copyright (C) 2003 - 2022 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -2309,6 +2309,9 @@
   register long
     i;
 
+  MagickBool
+    auto_orient = MagickFalse;
+
   unsigned int
     status;
 
@@ -2398,6 +2401,11 @@
               }
             break;
           }
+        if (LocaleCompare("auto-orient",option+1) == 0)
+          {
+            auto_orient = MagickTrue;
+            break;
+          }
         ThrowCompareException(OptionError,UnrecognizedOption,option);
       }
       case 'c':
@@ -2779,6 +2787,7 @@
   /*
     Apply any user settings to images prior to compare.
   */
+
   if (image_info->type != UndefinedType)
     {
       (void) SetImageType(reference_image,image_info->type);
@@ -2791,6 +2800,36 @@
       (void) TransformColorspace(compare_image,image_info->colorspace);
     }
 
+  if (auto_orient)
+    {
+      if (reference_image->orientation != UndefinedOrientation &&
+          reference_image->orientation != TopLeftOrientation)
+        {
+          Image
+            *orient_image;
+
+          orient_image = AutoOrientImage(reference_image,reference_image->orientation,exception);
+          if (orient_image != (Image *) NULL)
+            {
+              DestroyImageList(reference_image);
+              reference_image = orient_image;
+            }
+        }
+      if (compare_image->orientation != UndefinedOrientation &&
+          compare_image->orientation != TopLeftOrientation)
+        {
+          Image
+            *orient_image;
+
+          orient_image = AutoOrientImage(compare_image,compare_image->orientation,exception);
+          if (orient_image != (Image *) NULL)
+            {
+              DestroyImageList(compare_image);
+              compare_image = orient_image;
+            }
+        }
+    }
+
   /*
     If user has not indicated a preference, then use StoreMatte if
     either image has a matte channel.
@@ -2928,6 +2967,7 @@
   (void) puts("");
   (void) puts("Where options include:");
   (void) puts("  -authenticate value  decrypt image with this password");
+  (void) puts("  -auto-orient         orient (rotate) images so they are upright");
   (void) puts("  -colorspace type     alternate image colorspace");
   (void) puts("  -compress type       image compression type");
   (void) puts("  -debug events        display copious debugging information");
diff -r 28b759ad4ccd -r a0a3bc91a1fa magick/version.h
--- a/magick/version.h	Wed Mar 09 16:31:14 2022 -0600
+++ b/magick/version.h	Fri Mar 11 13:26:39 2022 -0600
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x262300
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 26,23,0
-#define MagickChangeDate   "20220305"
-#define MagickReleaseDate  "snapshot-20220305"
+#define MagickChangeDate   "20220311"
+#define MagickReleaseDate  "snapshot-20220311"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 28b759ad4ccd -r a0a3bc91a1fa utilities/gm.1
--- a/utilities/gm.1	Wed Mar 09 16:31:14 2022 -0600
+++ b/utilities/gm.1	Fri Mar 11 13:26:39 2022 -0600
@@ -1,4 +1,4 @@
-.TH gm 1 "2022/01/22" "GraphicsMagick"
+.TH gm 1 "2022/03/11" "GraphicsMagick"
 .TP
 .in 15
 .in 15
@@ -5891,6 +5891,9 @@
 .B "-authenticate \fI<string>"\fP
 \fRdecrypt image with this password
 .TP
+.B "-auto-orient"
+\fRorient (rotate) image so it is upright
+.TP
 .B "-colorspace \fI<value>"\fP
 \fRthe type of colorspace
 .TP
diff -r 28b759ad4ccd -r a0a3bc91a1fa www/Changelog.html
--- a/www/Changelog.html	Wed Mar 09 16:31:14 2022 -0600
+++ b/www/Changelog.html	Fri Mar 11 13:26:39 2022 -0600
@@ -35,6 +35,11 @@
 <div class="document">
 
 
+<p>2022-03-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+* magick/command.c (CompareImageCommand): Add -auto-orient support
+to 'compare'.  This tries to assure that the two images are right
+side up before comparing.</blockquote>
 <p>2022-03-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 * coders/jxl.c (WriteJXLImage): Work to update JXL writer code to
diff -r 28b759ad4ccd -r a0a3bc91a1fa www/compare.html
--- a/www/compare.html	Wed Mar 09 16:31:14 2022 -0600
+++ b/www/compare.html	Fri Mar 11 13:26:39 2022 -0600
@@ -163,6 +163,17 @@
 ALT=">" BORDER=0 height=14
 width=15><b><font face="Helvetica, Arial"
 ><font color="#00B04F"><font size="+1">
+    <a href="GraphicsMagick.html#details-auto-orient">-auto-orient</a>
+</font></font></font></b></td></tr></table>
+<table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>orient (rotate) image so it is upright</td></tr></table>
+<table BORDER=0 WIDTH="94%">
+<tr>
+<td width="3%"><br></td> 
+<td ALIGN=LEFT BGCOLOR="#FFFFFF">
+<img SRC="images/right_triangle_option.png"
+ALT=">" BORDER=0 height=14
+width=15><b><font face="Helvetica, Arial"
+><font color="#00B04F"><font size="+1">
     <a href="GraphicsMagick.html#details-colorspace">-colorspace</a> <i>&lt;value&gt;</i>
 </font></font></font></b></td></tr></table>
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>the type of colorspace</td></tr></table>
diff -r 28b759ad4ccd -r a0a3bc91a1fa www/gm.html
--- a/www/gm.html	Wed Mar 09 16:31:14 2022 -0600
+++ b/www/gm.html	Fri Mar 11 13:26:39 2022 -0600
@@ -7766,6 +7766,17 @@
 ALT=">" BORDER=0 height=14
 width=15><b><font face="Helvetica, Arial"
 ><font color="#00B04F"><font size="+1">
+    <a href="GraphicsMagick.html#details-auto-orient">-auto-orient</a>
+</font></font></font></b></td></tr></table>
+<table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>orient (rotate) image so it is upright</td></tr></table>
+<table BORDER=0 WIDTH="94%">
+<tr>
+<td width="3%"><br></td> 
+<td ALIGN=LEFT BGCOLOR="#FFFFFF">
+<img SRC="images/right_triangle_option.png"
+ALT=">" BORDER=0 height=14
+width=15><b><font face="Helvetica, Arial"
+><font color="#00B04F"><font size="+1">
     <a href="GraphicsMagick.html#details-colorspace">-colorspace</a> <i>&lt;value&gt;</i>
 </font></font></font></b></td></tr></table>
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>the type of colorspace</td></tr></table>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.