iMacros and ImageMagick Compare Sample Script
iMacros and ImageMagick Compare Sample Script
Hi! Guys. I just learned about Imagemagick and its powerful features. Despite of its simplicity, the noob like me is having a hard time combining different scripts to achieve my goal.
I actually want to take screen shots of our website homepage on a daily basis using iMacros, compare the screenshots (two atleast in a day) using ImageMagick and send an email to alert us if something changes (using vbscript). Is this possible? I would appreciate if you could provide me a sample script.
Thank you thank you!
I actually want to take screen shots of our website homepage on a daily basis using iMacros, compare the screenshots (two atleast in a day) using ImageMagick and send an email to alert us if something changes (using vbscript). Is this possible? I would appreciate if you could provide me a sample script.
Thank you thank you!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: iMacros and ImageMagick Compare Sample Script
I don't know vbscript as I am on a Mac. But the operation you are looking for is compare. See http://www.imagemagick.org/Usage/compare/
and http://www.imagemagick.org/script/compare.php
and http://www.imagemagick.org/script/compare.php
Re: iMacros and ImageMagick Compare Sample Script
Hi! fmw42. Thanks for your response. I'm currently looking the links that you gave me. I want to follow a sample command script of which the difference will be calculated and that a portion has changed. In this way, we don't have to check/look on the homepage on a regular basis. The script will alert us once there are changes. Thanks a lot.
Re: iMacros and ImageMagick Compare Sample Script
Thanks again. Anyone, who can provide a sample vbscript of comparing two images? I can do it in Batch but will need to have it done in vbscript. Thanks a lot!
Re: iMacros and ImageMagick Compare Sample Script
Also, can you tell me what kind of metric should I use to compare these images? I'm confused about the results I'm getting and how to use it to trigger the email function to send a message that something has changed on the website. I need to set values that should be the basis of the changes. Please help! Thank you in advance.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: iMacros and ImageMagick Compare Sample Script
see http://www.imagemagick.org/Usage/compare/#statistics
I would recommend either rmse ( 0 means a perfect match) or ncc ( 1 means a perfect match ) but use whichever is faster.
I would recommend either rmse ( 0 means a perfect match) or ncc ( 1 means a perfect match ) but use whichever is faster.
Re: iMacros and ImageMagick Compare Sample Script
Hi. Thanks for the tip.
I know you've also mentioned that you are not into vbscript but this question is for those who happen to pass by on this post and would love to give their 2 cents.
I would like to convert this command line
-compare -metric rmse image1.png image2.png diff.png
and be able to get its value which should be compared to 1 or zero.
Any help frm you will be very much appreciated. Thanks again!
I know you've also mentioned that you are not into vbscript but this question is for those who happen to pass by on this post and would love to give their 2 cents.
I would like to convert this command line
-compare -metric rmse image1.png image2.png diff.png
and be able to get its value which should be compared to 1 or zero.
Any help frm you will be very much appreciated. Thanks again!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: iMacros and ImageMagick Compare Sample Script
This is not correct syntax. First there is no -compare. It is just compare. Second you want to get the comparison stats and not the difference image.-compare -metric rmse image1.png image2.png diff.png
compare -metric rmse rose: rose: null:
In unix,
values=`compare -metric rmse rose: rose: null: 2>&1`
val1=`echo "$values" | cut -d\ -f 1`
rmsepercent=`convert xc: -format "%[fx: 100*$val1/quantumrange]" info:`
echo "$rmsepercent"
The result is 0, since both images are the same. Thus a perfect match is rmse=0.
The first number is the rmse difference in raw values (in range 0 to QuantumRange for your IM compile, default is Q16 so 0 to 655535). The second number is more useful as it is in the range (0 to 1). The 2>&1 is to capture the output from std error.
Some windows user will have to help you convert this.
Last edited by fmw42 on 2011-04-01T20:31:27-07:00, edited 1 time in total.
Re: iMacros and ImageMagick Compare Sample Script
Hi again. You've been really helpful. But I got one more request, I don't know unix, can I have the sample equivalent of it in batch using windows command line? Thank you thank you so much. Really appreciate your time and effort to help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: iMacros and ImageMagick Compare Sample Script
lizac wrote:Hi again. You've been really helpful. But I got one more request, I don't know unix, can I have the sample equivalent of it in batch using windows command line? Thank you thank you so much. Really appreciate your time and effort to help.
Sorry, I don't know or use Windows or Bat files. So perhaps some other kind Windows user can translate that for you.
Re: iMacros and ImageMagick Compare Sample Script
Hi! fmw42. No problem. I actually scoured the forum again and it turns out that your answer to other related questions have also widen my understanding on what you meant with your code. You're a big help.
On another note, I would like to ask how can I use the rmse not to give false information. Here's the scenario actually.
1. I have a program (imacros) that will take the page screenshot with 5 hours interval within a day.
2. After the last image has been taken, the ImageMagick will compare the first screenshot and last screenshot.
3. The page has actually a dynamic area, particularly in the footer. This is the area is a javascript for verisign verification (https://sealinfo.verisign.com/splash?fo ... om&lang=en).
4. I did some testing and there are always differences on this area which is not what I wanted. My tool only takes the screenshot of all pages. How can I use the compare metric rmse or others (if it fits my requirement) not to alert me each time this is the only area that have been changed.
With this scenario, I just don't think that testing the result against zero is not applicable. Do you have any idea? Thank you so much!
On another note, I would like to ask how can I use the rmse not to give false information. Here's the scenario actually.
1. I have a program (imacros) that will take the page screenshot with 5 hours interval within a day.
2. After the last image has been taken, the ImageMagick will compare the first screenshot and last screenshot.
3. The page has actually a dynamic area, particularly in the footer. This is the area is a javascript for verisign verification (https://sealinfo.verisign.com/splash?fo ... om&lang=en).
4. I did some testing and there are always differences on this area which is not what I wanted. My tool only takes the screenshot of all pages. How can I use the compare metric rmse or others (if it fits my requirement) not to alert me each time this is the only area that have been changed.
With this scenario, I just don't think that testing the result against zero is not applicable. Do you have any idea? Thank you so much!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: iMacros and ImageMagick Compare Sample Script
Best suggestion is to blank out the same area on each image with some same constant color before doing the compare. You can either draw over the images and fill with a constant color or have some fixed size constant color image that you overlay over each image in the same area. I think the latter is more efficient.
see
http://www.imagemagick.org/Usage/layers/
in particular, -draw and either composite or convert -composite.
If the area is at the bottom, then
convert backgroundimage colorimage -gravity south -composite resultimage
should do the trick. Or you can create the color image on the fly
convert backgroundimage \( -size WxH xc:somecolor \) -gravity south -composite resultimage
see
http://www.imagemagick.org/Usage/layers/
in particular, -draw and either composite or convert -composite.
If the area is at the bottom, then
convert backgroundimage colorimage -gravity south -composite resultimage
should do the trick. Or you can create the color image on the fly
convert backgroundimage \( -size WxH xc:somecolor \) -gravity south -composite resultimage
Re: iMacros and ImageMagick Compare Sample Script
Hi! fmw42.
Thanks for your response and I think that's the best thing to do for us not to get false reports.
I'm almost done with my coding but the requirements of the program has been changed. I'm actually lost at this time as I have limited knowledge on batch or vbscript. Anyways, for those who may have idea, kindly share your two cents here. I badly need help.
The scenario is: On a daily basis, one screenshot will be taken for a certain page then compare it to the next screenshot. last screenshot will be compared to the new one.
ex.
day 1 - first.png
day 2 - second.png
compare first.png second.png difference.png
day 3 - third.png
compare third.png second.png difference.png
day 4 - fourth.png
compare fourth.png third.png difference.png
and so on...
basically, the last screenshot will be compared on the recent screenshot. How can I do that in batch/vbs?
I don't want to keep all the old screenshots. If it's possible to use variable in Imagemagick then the program will only overwrite the old screenshots.
Any help from you guys will be very much appreciated. This is actually only a part of the program because I have a long list of pages that need to be checked. oh, my brain is starting to ache. =)
Thanks for your response and I think that's the best thing to do for us not to get false reports.
I'm almost done with my coding but the requirements of the program has been changed. I'm actually lost at this time as I have limited knowledge on batch or vbscript. Anyways, for those who may have idea, kindly share your two cents here. I badly need help.
The scenario is: On a daily basis, one screenshot will be taken for a certain page then compare it to the next screenshot. last screenshot will be compared to the new one.
ex.
day 1 - first.png
day 2 - second.png
compare first.png second.png difference.png
day 3 - third.png
compare third.png second.png difference.png
day 4 - fourth.png
compare fourth.png third.png difference.png
and so on...
basically, the last screenshot will be compared on the recent screenshot. How can I do that in batch/vbs?
I don't want to keep all the old screenshots. If it's possible to use variable in Imagemagick then the program will only overwrite the old screenshots.
Any help from you guys will be very much appreciated. This is actually only a part of the program because I have a long list of pages that need to be checked. oh, my brain is starting to ache. =)