How to use both convert and compare in one command?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mattalexx

How to use both convert and compare in one command?

Post by mattalexx »

I would like to use convert to resize an image to the size of another image before I use compare to compare them. I want to do this in one command so I can avoid saving a temp file from convert to use in compare.

I wish I wasn't so bad with standard output and stuff like that. Is there anyway to accomplish what I'm after?

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to use both convert and compare in one command?

Post by fmw42 »

This does not work as compare does not seem to allow parenthesis processing and objects to -resize

compare -metric rmse image1.jpg \( image2.jpg -resize WIDTHxHEIGHT \) null:


But you can do this by piping the output from convert (as temporary miff file that automatically goes away) to compare.

convert image2.jpg -resize WIDTHxHEIGHT miff:- | compare -metric rmse - image1.jpg null:
mattalexx

Re: How to use both convert and compare in one command?

Post by mattalexx »

fmw42 wrote: convert image2.jpg -resize WIDTHxHEIGHT miff:- | compare -metric rmse - image1.jpg null:
Awesome, thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to use both convert and compare in one command?

Post by anthony »

Only convert and montage allows the use of parenthesis. and only compare allows the use of -metric.

You can get some compare handling in "convert" by using a "Difference" composition of the two images, but that is about as far as it goes.
http://www.imagemagick.org/Usage/compare/#difference
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply