Skip to content

Commit

Permalink
added autoorient feature
Browse files Browse the repository at this point in the history
  • Loading branch information
naithar authored and Sergey Minakov committed Nov 23, 2018
1 parent 0af8b2f commit 496922a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Sources/MagickWand/Wand/ImageWand/ImageWand+Resize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 23 additions & 1 deletion Tests/MagickWandTests/ImageWandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 496922a

Please sign in to comment.