summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Wey2013-02-15 16:32:55 +0100
committerMike Wey2013-02-15 16:32:55 +0100
commit4f3629c1e69052ae188e253b1b890233e6971437 (patch)
tree5ca280a3f713d11a145e755df7dd788a75a34925
parent4ee3064488597e65569acae10492ddd007851288 (diff)
Add an autoOrient function that rotates/flips the image based on the
EXIF information.
-rw-r--r--dmagick/Image.d45
1 files changed, 45 insertions, 0 deletions
diff --git a/dmagick/Image.d b/dmagick/Image.d
index d69b23b..21719e5 100644
--- a/dmagick/Image.d
+++ b/dmagick/Image.d
@@ -512,6 +512,51 @@ class Image
}
/**
+ * 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.
*