问题
I tried to use apt-get install imagemagick
command to install ImageMagick on my Debian Wheezy. But when I try to diff images, I get following error:
root@work:/home/tests/YAML_SHOTS/en-us# convert 1.png 2.png -metric RMSE -compare 3.png
convert.im6: unrecognized option `-metric' @ error/convert.c/ConvertImageCommand/2060.
Secondly, I tried to install ImageMagick from binary source (described here: http://www.imagemagick.org/script/install-source.php#unix). But it does not install the convert
executable command.
How can I fix that?
P.S. If I remove -metric
option, I get one more error:
convert.im6: unrecognized option `-compare' @ error/convert.c/ConvertImageCommand/1107.
回答1:
Use the compare utility directly.
compare 1.png 2.png -metric RMSE 3.png
But if you want to generate a image diff without sending the metrics to STDERR, define the -metric
and -compare
before the image stack.
convert -metric RMSE -compare 1.png 2.png 3.png
回答2:
Assuming your ImageMagick version is a fairly recent one, try this command:
compare -metric phash 1.png 2.png delta.png
7.61662
The returned pHash value of 7.61662
indicates, that there was indeed some difference in the compared image, and that the delta.png
will show some red highlighted pixels.
The red pixels indicate there is a difference in the color values of the respective pixels in the two compared images. White pixels indicate identical color values. The grayed-out, light color background of the delta.png is derived from the first image, in order to help identify better the differences in more complex images. If you do not want the background, run this modified command:
compare -metric phash 1.png 2.png -compose src delta.png
Above illustration depicts 1.png
(left), 2.png
(center) and delta.png
(right).
Compare this to
compare -metric phash 1.png 1.png delta2.png
0
Here there is no difference, the pHash value is 0
, and the delta2.png
doesn't show any red pixels:
Above illustration depicts 1.png
(left), 1.png
(center) and delta2.png
(right).
By default, the compare
command will run with 72 PPI. If you need a higher resolution (for example, when comparing PDF pages), add -density 300
as the first parameter to get 300 PPI.
来源:https://stackoverflow.com/questions/26588581/imagemagick-compare-executable-unrecognized-option-metric-error-convert-c