From: cristy Date: Tue, 1 Jan 2013 14:37:35 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4506 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa5f6c7d8951fffaccad70fa706701129f0a82bf;p=imagemagick --- diff --git a/MagickCore/transform.c b/MagickCore/transform.c index 84da70692..bf0208460 100644 --- a/MagickCore/transform.c +++ b/MagickCore/transform.c @@ -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" @@ -71,6 +72,95 @@ % % % % % % +% 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); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % C h o p I m a g e % % % % % diff --git a/MagickCore/transform.h b/MagickCore/transform.h index 7fd1d4ad8..f90e124d0 100644 --- a/MagickCore/transform.h +++ b/MagickCore/transform.h @@ -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 *), diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 639c5db15..2037a85fb 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -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; diff --git a/MagickWand/operation.c b/MagickWand/operation.c index 5b40fc1f8..bf5c30b91 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -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); diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index b2d921089..dfb1b9627 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -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 */