From 4f3629c1e69052ae188e253b1b890233e6971437 Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Fri, 15 Feb 2013 16:32:55 +0100 Subject: Add an autoOrient function that rotates/flips the image based on the EXIF information. --- dmagick/Image.d | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dmagick/Image.d b/dmagick/Image.d index d69b23b..21719e5 100644 --- a/dmagick/Image.d +++ b/dmagick/Image.d @@ -511,6 +511,51 @@ class Image DMagickException.throwException(&(imageRef.exception)); } + /** + * Adjusts an image so that its orientation is suitable for viewing + * (i.e. top-left orientation). Note that only some models of modern + * digital cameras can tag an image with the orientation. + */ + void autoOrient() + { + final switch( this.orientation ) + { + case OrientationType.UndefinedOrientation: + case OrientationType.TopLeftOrientation: + return; + + case OrientationType.TopRightOrientation: + flop(); + break; + + case OrientationType.BottomRightOrientation: + rotate(180); + break; + + case OrientationType.BottomLeftOrientation: + flip(); + break; + + case OrientationType.LeftTopOrientation: + transpose(); + break; + + case OrientationType.RightTopOrientation: + rotate(90); + break; + + case OrientationType.RightBottomOrientation: + transverse(); + break; + + case OrientationType.LeftBottomOrientation: + rotate(270); + break; + } + + orientation = OrientationType.TopLeftOrientation; + } + /** * Changes the value of individual pixels based on the intensity * of each pixel channel. The result is a high-contrast image. -- cgit v1.2.3