Open xyzzy-plugh-plover opened 1 year ago
@xyzzy-plugh-plover
compare
tool for the actual comparison, so refer to that for details. We are not passing a -metric
flag, so as far as I know we should be getting precise matches with -f 0
.git diff
, but in principle I have no problem with that. The exit codes for this script haven't been defined up to now.So yes, I'd be happy to take those patches. Are you sure you want to put them here though? It sounds like whatever you're doing might just be better working directly with ImageMagick. Is diff-image
adding any value for you? It sounds like what you want is only a few lines of wrapper around ImageMagick compare
or identify
anyway.
I found your project when I was looking for various image comparison features. Given that I'm implementing them for myself, I figured it makes sense to share them so others can use them, too, and that it's better to have one good tool (yours) that provides all the functionality instead of 2 separate tools with slightly different capabilities.
I've made some other improvements while understanding your script which I'd be happy to also share. Many of them just simplify the code & simultaneously make it more performant, while some improve, in my mind, the stdout output; if you prefer the existing or other output, I can modify my changes to conform to your preference.
Do you want a bunch of small PRs, or could I just submit one PR, then you tell me if you want me to back out or modify any of my proposed changes? Let me know what works for you.
Smaller PRs would be best, thanks. They're easier to review that way.
I don't mind adding extra features. The principles I'll be sticking to are:
git diff
/ git diff-image
must keep working (I presume most users find the package because they're looking specifically for that).After that, I don't mind adding extra flags or output options or whatever.
Thanks. I'll open PRs one at a time starting with simple cleanup ones, then non-output changes, then output changes.
I don't have Linux to test, but I can test on macOS.
Would you accept a PR (or separate PRs) for
diff-image
that:-f 0
? (i.e. does 0 fuzz require an exact match?). If not already handled by-f 0
, this could be specified by-f x
or-x
(the latter should either be mutually exclusive with-f
, or one should always override the other, or there should be a defined order precedence, like first argument is used or last argument is used)identify -format %# <file>
could be run for each argument file & compared, which seems to be faster than thecompare
. If "exact mode" isn't specified, and ifcompare
can output programmatic values other than equals/not equals (like "10% different", or "491 pixels different"), then that info could be included in the stdout message.