diff --git a/Sources/BrightroomEngine/Core/EditingStack.Edit.swift b/Sources/BrightroomEngine/Core/EditingStack.Edit.swift index 700e3f18..36309ebf 100644 --- a/Sources/BrightroomEngine/Core/EditingStack.Edit.swift +++ b/Sources/BrightroomEngine/Core/EditingStack.Edit.swift @@ -32,6 +32,7 @@ extension EditingStack { crop.imageSize } + /// In orientation.up public var crop: EditingCrop public var filters: Filters = .init() public var drawings: Drawings = .init() diff --git a/Sources/BrightroomEngine/Core/EditingStack.swift b/Sources/BrightroomEngine/Core/EditingStack.swift index 686e4fb7..e77b44ca 100644 --- a/Sources/BrightroomEngine/Core/EditingStack.swift +++ b/Sources/BrightroomEngine/Core/EditingStack.swift @@ -412,21 +412,27 @@ open class EditingStack: Hashable, StoreComponentType { public func makeCroppedCIImage(loadedState: State.Loaded) -> CIImage { do { + let orientation = loadedState.metadata.orientation let crop = loadedState.currentEdit.crop + + // orientation is not respected let image = loadedState.editingSourceCGImage - let imageSize = image.size - + // orientation-respected + let imageSize = image.size + .applying(cgOrientation: orientation) let scaledCrop = crop.scaledWithPixelPerfect( maxPixelSize: max(imageSize.width, imageSize.height) ) return try image + .oriented(orientation) .croppedWithColorspace( - to: scaledCrop.cropExtent, adjustmentAngleRadians: scaledCrop.aggregatedRotation.radians) + to: scaledCrop.cropExtent, adjustmentAngleRadians: scaledCrop.aggregatedRotation.radians + ) ._makeCIImage( - orientation: loadedState.metadata.orientation, + orientation: .up, device: mtlDevice, usesMTLTexture: options.usesMTLTextureForEditingImage )