python-needle / needle

Automated tests for your CSS.
https://needle.readthedocs.io/
Other
590 stars 50 forks source link

Add imagemagick engine #35

Closed mbertheau closed 9 years ago

mbertheau commented 9 years ago

I find the diffs imagemagick produces much easier to work with.

See http://stackoverflow.com/questions/5132749/imagemagick-diff-an-image for examples.

This engine behaves a bit differently than the perceptualdiff engine. It leaves the new screenshot around only if there are differences. When there's no differences, an existing differences image from an earlier run is deleted. It also uses cmp at first to quickly skip unchanged screenshots.

mbertheau commented 9 years ago

Thank you for the review!

jphalip commented 9 years ago

Thanks a lot for this. I'd love to add Imagemagick support. It'd be easier if we had test though. Do you think you could add some as part of this PR?

I realize that the perceptualdiff backend doesn't have tests either. We should add some too, but that's of course outside the scope of this PR.

mbertheau commented 9 years ago

Sorry, I'm not using this anymore. Feel free to close.

jphalip commented 9 years ago

No worries. Leaving this ticket open as it's a useful feature I hope can be merged at some point. Hopefully some tests can be added.

jphalip commented 9 years ago

@mbertheau So I have written some tests for this and could merge it soon. However, I first wanted to ask you, what is the purpose of the cmp_cmd command? Isn't compare_cmd all that needs to be executed? Thanks!

mbertheau commented 9 years ago

@jphalip I believe cmp was much faster at recognizing files that are the same than compare. For that reason I first tried cmp, and when the files were equal, I could return that result quickly. If they weren't the same, I used compare to get a difference metric.

jphalip commented 9 years ago

@mbertheau Ok, I see. Is cpm supposed to be part of Imagemagick itself? I've installed Imagemagick via brew install on my Mac, but that seems to only give me compare, not cmp.

mbertheau commented 9 years ago

cmp is part of diffutils on Ubuntu. I don't know about OS X, sorry :)

jphalip commented 9 years ago

@mbertheau Ok, I see, thank you :) I don't think we can assume that all users will have cmp available, so we should probably leave that out. I'll try to push the feature with tests soon.