From 496922aa45ecd17336ff42b5624940f6f41cb7bc Mon Sep 17 00:00:00 2001 From: Sergey Minakov Date: Wed, 17 Jan 2018 22:04:53 +0300 Subject: [PATCH] added autoorient feature --- .../Wand/ImageWand/ImageWand+Resize.swift | 5 ++++ Tests/MagickWandTests/ImageWandTests.swift | 24 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Sources/MagickWand/Wand/ImageWand/ImageWand+Resize.swift b/Sources/MagickWand/Wand/ImageWand/ImageWand+Resize.swift index bb97a9c..d22264c 100644 --- a/Sources/MagickWand/Wand/ImageWand/ImageWand+Resize.swift +++ b/Sources/MagickWand/Wand/ImageWand/ImageWand+Resize.swift @@ -30,6 +30,11 @@ import Foundation extension ImageWand { + public func autoOrient() -> Bool { + return MagickAutoOrientImage(self.pointer).bool + } + + // https://www.imagemagick.org/api/magick-image.php // TODO: Resize modes. like AspectFill, AspectFit. // TODO: resized, rescaled -> ImageWand diff --git a/Tests/MagickWandTests/ImageWandTests.swift b/Tests/MagickWandTests/ImageWandTests.swift index 2dd3c40..11b1b20 100644 --- a/Tests/MagickWandTests/ImageWandTests.swift +++ b/Tests/MagickWandTests/ImageWandTests.swift @@ -33,7 +33,29 @@ class ImageWandTests: XCTestCase { XCTAssertEqual(imageWand?.size.height, 50, "Created `ImageWand` has wrong size") XCTAssertEqual(imageWand?.size, MagickWand.Size(width: 100, height: 50), "Created `ImageWand` has wrong size") - print(imageWand!.resolution) + self.basicChecks(forWand: imageWand, size: Size.init(width: 100, height: 5)) + } + + private let variants: [(name: String, type: String)] = [ + ("PNG", "png"), + ("JPEG", "jpeg"), + ("PDF", "pdf"), + ("GIF", "gif"), + //("SVG", "svg"), //FIXME: cannot create or read + ("TIFF", "tiff"), + ] + + private func performVariants(action: (String, String) -> Void) { + let folder = "images/converted/" + self.variants.forEach { + let file = folder + $0.name + print("Running test for file at \(file).\($0.type)") + action(file, $0.type) + } + } + + func testInitWithData() { + self.performVariants(action: self.initWithData(file:ofType:)) } func testClone() {