]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 1 Jan 2013 14:37:35 +0000 (14:37 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 1 Jan 2013 14:37:35 +0000 (14:37 +0000)
MagickCore/transform.c
MagickCore/transform.h
MagickWand/mogrify.c
MagickWand/operation.c
PerlMagick/Magick.xs

index 84da706922b79aab735f18ee34fd772f26fc805f..bf02084605487b1dcd0fc21fc44bb0b643344223 100644 (file)
@@ -47,6 +47,7 @@
 #include "MagickCore/color-private.h"
 #include "MagickCore/colorspace-private.h"
 #include "MagickCore/composite.h"
+#include "MagickCore/distort.h"
 #include "MagickCore/draw.h"
 #include "MagickCore/effect.h"
 #include "MagickCore/exception.h"
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   A u t o O r i e n t I m a g e                                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  AutoOrientImage() adjusts an image so that its orientation is suitable for
+%  viewing (i.e. top-left orientation).
+%
+%  The format of the AutoOrientImage method is:
+%
+%      Image *AutoOrientImage(const Image *image,
+%        const OrientationType orientation,ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%    o orientation: Current image orientation.
+%
+%    o exception: Return any errors or warnings in this structure.
+%
+*/
+MagickExport Image *AutoOrientImage(const Image *image,
+  const OrientationType orientation,ExceptionInfo *exception)
+{
+  Image
+    *orient_image;
+
+  assert(image != (const Image *) NULL);
+  assert(image->signature == MagickSignature);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickSignature);
+  orient_image=(Image *) NULL;
+  switch(orientation)
+  {
+    case UndefinedOrientation:
+    case TopLeftOrientation:
+    default:
+    {
+      orient_image=CloneImage(image,0,0,MagickTrue,exception);
+      break;
+    }
+    case TopRightOrientation:
+    {
+      orient_image=FlopImage(image,exception);
+      break;
+    }
+    case BottomRightOrientation:
+    {
+      orient_image=RotateImage(image,180.0,exception);
+      break;
+    }
+    case BottomLeftOrientation:
+    {
+      orient_image=FlipImage(image,exception);
+      break;
+    }
+    case LeftTopOrientation:
+    {
+      orient_image=TransposeImage(image,exception);
+      break;
+    }
+    case RightTopOrientation:
+    {
+      orient_image=RotateImage(image,90.0,exception);
+      break;
+    }
+    case RightBottomOrientation:
+    {
+      orient_image=TransverseImage(image,exception);
+      break;
+    }
+    case LeftBottomOrientation:
+    {
+      orient_image=RotateImage(image,270.0,exception);
+      break;
+    }
+  }
+  if (orient_image != (Image *) NULL)
+    orient_image->orientation=TopLeftOrientation;
+  return(orient_image);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   C h o p I m a g e                                                         %
 %                                                                             %
 %                                                                             %
index 7fd1d4ad855fd84a8e22dd4e4e13dd2f73a26729..f90e124d08bd5a350d0075f5a76f66ef68a2b7d3 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
 #endif
 
 extern MagickExport Image
+  *AutoOrientImage(const Image *,const OrientationType,ExceptionInfo *),
   *ChopImage(const Image *,const RectangleInfo *,ExceptionInfo *),
   *ConsolidateCMYKImages(const Image *,ExceptionInfo *),
   *CropImage(const Image *,const RectangleInfo *,ExceptionInfo *),
index 639c5db159457b15ffa38dae591e8f9daf04a8ec..2037a85fb0f68c1b52ca8c5e491d9a9df2e31519 100644 (file)
@@ -874,48 +874,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
         if (LocaleCompare("auto-orient",option+1) == 0)
           {
             (void) SyncImageSettings(mogrify_info,*image,exception);
-            switch ((*image)->orientation)
-            {
-              case TopRightOrientation:
-              {
-                mogrify_image=FlopImage(*image,exception);
-                break;
-              }
-              case BottomRightOrientation:
-              {
-                mogrify_image=RotateImage(*image,180.0,exception);
-                break;
-              }
-              case BottomLeftOrientation:
-              {
-                mogrify_image=FlipImage(*image,exception);
-                break;
-              }
-              case LeftTopOrientation:
-              {
-                mogrify_image=TransposeImage(*image,exception);
-                break;
-              }
-              case RightTopOrientation:
-              {
-                mogrify_image=RotateImage(*image,90.0,exception);
-                break;
-              }
-              case RightBottomOrientation:
-              {
-                mogrify_image=TransverseImage(*image,exception);
-                break;
-              }
-              case LeftBottomOrientation:
-              {
-                mogrify_image=RotateImage(*image,270.0,exception);
-                break;
-              }
-              default:
-                break;
-            }
-            if (mogrify_image != (Image *) NULL)
-              mogrify_image->orientation=TopLeftOrientation;
+            mogrify_image=AutoOrientImage(*image,(*image)->orientation,
+              exception);
             break;
           }
         break;
index 5b40fc1f827fbb84c752886051e35480616966dd..bf5c30b91ba987a71fb7e3b2c6243c26ebf277e4 100644 (file)
@@ -1800,49 +1800,7 @@ static void CLISimpleOperatorImage(MagickCLI *cli_wand,
         }
       if (LocaleCompare("auto-orient",option+1) == 0)
         {
-          /* This should probably be a MagickCore function */
-          switch (_image->orientation)
-          {
-            case TopRightOrientation:
-            {
-              new_image=FlopImage(_image,_exception);
-              break;
-            }
-            case BottomRightOrientation:
-            {
-              new_image=RotateImage(_image,180.0,_exception);
-              break;
-            }
-            case BottomLeftOrientation:
-            {
-              new_image=FlipImage(_image,_exception);
-              break;
-            }
-            case LeftTopOrientation:
-            {
-              new_image=TransposeImage(_image,_exception);
-              break;
-            }
-            case RightTopOrientation:
-            {
-              new_image=RotateImage(_image,90.0,_exception);
-              break;
-            }
-            case RightBottomOrientation:
-            {
-              new_image=TransverseImage(_image,_exception);
-              break;
-            }
-            case LeftBottomOrientation:
-            {
-              new_image=RotateImage(_image,270.0,_exception);
-              break;
-            }
-            default:
-              break;
-          }
-          if (new_image != (Image *) NULL)
-            new_image->orientation=TopLeftOrientation;
+          new_image=AutoOrientImage(_image,_image->orientation,_exception);
           break;
         }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
index b2d921089263e957fde9ed158f02497a57f82c41..dfb1b9627a45f6c3282ae69e840b67c7a653ed83 100644 (file)
@@ -10139,46 +10139,7 @@ Mogrify(ref,...)
         }
         case 101:  /* AutoOrient */
         {
-          switch (image->orientation)
-          {
-            case TopRightOrientation:
-            {
-              image=FlopImage(image,exception);
-              break;
-            }
-            case BottomRightOrientation:
-            {
-              image=RotateImage(image,180.0,exception);
-              break;
-            }
-            case BottomLeftOrientation:
-            {
-              image=FlipImage(image,exception);
-              break;
-            }
-            case LeftTopOrientation:
-            {
-              image=TransposeImage(image,exception);
-              break;
-            }
-            case RightTopOrientation:
-            {
-              image=RotateImage(image,90.0,exception);
-              break;
-            }
-            case RightBottomOrientation:
-            {
-              image=TransverseImage(image,exception);
-              break;
-            }
-            case LeftBottomOrientation:
-            {
-              image=RotateImage(image,270.0,exception);
-              break;
-            }
-            default:
-              break;
-          }
+          image=AutoOrientImage(image,image->orientation,exception);
           break;
         }
         case 102:  /* AdaptiveBlur */