Enumeration

UIImage.Orientation

A value describing the intended display orientation for an image.

Declaration

enum Orientation : Int

Overview

Orientation values are commonly found in image metadata, and specifying image orientation correctly can be important both for displaying the image and for certain kinds of image processing.

The UIImage class automatically handles the transform necessary to present an image in the correct display orientation according to its orientation metadata, so an image object's imageOrientation property simply indicates which transform was applied.

For example, an iOS device camera always encodes pixel data in the camera sensor's native landscape orientation, along with metadata indicating the camera orientation. When UIImage loads a photo shot in portrait orientation, it automatically applies a 90° rotation before displaying the image data, and the image's imageOrientation value of UIImage.Orientation.right indicates that this rotation has been applied.

Figure 1

UIImage rotates an image with right orientation for correct display

UIImage rotates an image with right orientation for correct display

Topics

Image Orientations

case up

The original pixel data matches the image's intended display orientation.

case down

The image has been rotated 180° from the orientation of its original pixel data.

case left

The image has been rotated 90° counterclockwise from the orientation of its original pixel data.

case right

The image has been rotated 90° clockwise from the orientation of its original pixel data.

case upMirrored

The image has been horizontally flipped from the orientation of its original pixel data.

case downMirrored

The image has been vertically flipped from the orientation of its original pixel data.

case leftMirrored

The image has been rotated 90° clockwise and flipped horizontally from the orientation of its original pixel data.

case rightMirrored

The image has been rotated 90° counterclockwise and flipped horizontally from the orientation of its original pixel data.

See Also

Image Attributes

var imageOrientation: UIImage.Orientation

The orientation of the receiver’s image.

var flipsForRightToLeftLayoutDirection: Bool

A Boolean value that indicates whether the image should flip in a right-to-left layout.

var resizingMode: UIImage.ResizingMode

The resizing mode of the image.

enum UIImage.ResizingMode

Specifies the possible resizing modes for an image.

var duration: TimeInterval

Returns the time interval used to display an animated image.

var capInsets: UIEdgeInsets

The end-cap insets.

var alignmentRectInsets: UIEdgeInsets

The alignment metadata used to position the image during layout.

var traitCollection: UITraitCollection

Returns the trait collection that describes the image.