Page 1 of 1

ImageMagic compare as an external tool

Posted: 2013-06-02T00:55:22-07:00
by Cu3ert
Hi,

I am new to this forum and new to ImageMagick, so bear with me :)

Last night I tried to setup ImageMagick as an external tool for DiffMerge (http://www.sourcegear.com/diffmerge/) so that when I do a diff on image files in a version control system, I will see what has changed.

I successfully installed imageMagick and am able to run compare command from the terminal

Code: Select all

  compare -verbose  ~/path/image_latest.png ~/path/image_local.png ~/path/compare.png
I also created an AppleScript and made this into an .app file. This also works when I double click on the app icon in finder.

Code: Select all

  do shell script "/opt/local/bin/compare " & "~/path/image_latest.png " & "~/path/image_local.png " & "~/path/compare.png" & ";exit 0"
But when I try to setup this in DiffMerge using either the compare command or the CompareIM.app I made, nothing happens at all.

Pathname to external Tool:
/Applications/CompareIM.app
/opt/local/bin/compare

Commandline arguments for external tool:
"%LEFT_PATH%" "%RIGHT_PATH%" ~/Desktop/compare.png

I tried switching to an image editor tool and it opens with the images, any idea why ImageMagick does not play.

Any pointers on how to debug this. I tried something like

Code: Select all

 compare -verbose ... > ~/Desktop/imcompare.txt 
But no output gets written in the file. It is always empty.

Any help is highly appreciated. Thanks in advance :)

Re: ImageMagic compare as an external tool

Posted: 2013-06-02T01:09:31-07:00
by Cu3ert
Ok, I think I found the problem. It has something to do how DiffMerge handles the commandline arguments. If I removed them completely the hardcoded script in the AppleScript works fine.

Re: ImageMagic compare as an external tool

Posted: 2013-06-02T03:03:22-07:00
by Cu3ert
I realize this is not actually an issue with ImageMagic, but in case someone finds this useful I share how to resolve this. The cause seemed to be that AppleScripts saved as .app do not handle arguments correctly as described here:
http://stackoverflow.com/questions/1441 ... mmand-line

Saving the AppleScript as Script instead and using

Pathname to External Tool

Code: Select all

osascript /Applications/CompareIM.scpt 
Makes it work!

edit: here is the applescript

Code: Select all

on run argv
	do shell script "/opt/local/bin/compare " & item 1 of argv & " " & item 2 of argv & " " & item 3 of argv
end run

Re: ImageMagic compare as an external tool

Posted: 2013-06-26T18:39:14-07:00
by anthony
Warning... if the two images are not the same size it will fail!