Skip to content Skip to sidebar Skip to footer

Problem Getting Terminal Output From Imagemagick's Compare.exe ( Either By Pipe Or Python )

I'm fairly new to python, but have a fair amount of experience with other languages. I wonder if anyone can help. The Problem I'm trying to incorporate the comparison of two images

Solution 1:

The compare tool outputs the result on stderr. Of course that totally does not make sense, but to work around it you need to forward stderr to a file (instead of stdout)

compare -metric AE -fuzz 20001.png 2.png diff.png 2> tmp.txt

You would really be better off using the Python ImageMagick module. The EXE file does not even return a non-zero value if an error occurs, so you can't really use it reasonably in a batch script.

Solution 2:

Seems like you want PythonMagick.

EDIT:

Ok, based on AndiDog's answer, here's what your Popen call should look like:

myOutput=subprocess.Popen("C:\\usr\\local\\bin\\att\\compare.exe -metric AE -fuzz 100 1.png 2.png mask.png", stderr=subprocess.PIPE)

Or, if stdout also prints useful information, you could do this:

myOutput=subprocess.Popen("C:\\usr\\local\\bin\\att\\compare.exe -metric AE -fuzz 100 1.png 2.png mask.png", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

Still, why use Popen when you can use ImageMagick directly through Python bindings?

Post a Comment for "Problem Getting Terminal Output From Imagemagick's Compare.exe ( Either By Pipe Or Python )"