I'm trying to run the ImageMagic compare command from within Xcode using swift, however, even though I seem to be able to get the image difference values, it doesn't seem to be able to create a comparison image file. As you probably know, the syntax of the compare function should look something like this:
Code: Select all
compare -metric MAE image1.jpg image2.jpg resultimage.jpg
Code: Select all
@discardableResult
func shell(_ args: String...) -> Int32 {
let task = Process()
task.launchPath = "/usr/local/bin/compare"
task.arguments = args
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
shell("-metric", "MAE", "/Users/CurrentUser/Desktop/TestExport/image1.jpg", "/Users/CurrentUser/Desktop/TestExport/image2.jpg", "/Users/CurrentUser/Desktop/TestExport/resultimage.jpg" )
Code: Select all
5.36454 (8.18576e-05)compare: unable to open image '/Users/CurrentUser/Desktop/TestExport/resultimage.jpg': Operation not permitted @ error/blob.c/OpenBlob/2691.
If I run compare command from within Terminal manually, everything works as expected. I've installed ImageMagick while using "brew" tool and it shows no errors whatsoever.
Code: Select all
Version: ImageMagick 7.0.4-4 Q16 x86_64 2017-01-15 http://www.imagemagick.org