#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 %
% %
% %
#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 *),
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;
}
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);
}
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 */