-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the diffPath optional #112
Make the diffPath optional #112
Conversation
bin/Main.ml
Outdated
if Option.is_some diffPath then | ||
IO1.saveImage diffOutput @@ Option.get diffPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to be a match
instead.
if Option.is_some diffPath then | |
IO1.saveImage diffOutput @@ Option.get diffPath; | |
match diffPath with | |
| None -> () | |
| Some path -> IO1.saveImage diffOutput path; |
or even just an Option.iter:
if Option.is_some diffPath then | |
IO1.saveImage diffOutput @@ Option.get diffPath; | |
diffPath |> Option.iter (IO1.saveImage diffOutput); |
I am on my phone currently. So its not tested and formatting might be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to use Option.iter
.
odiff.js should probably also be changed 🙂 |
I copied the binary manually to
so I'm not sure if |
fe427a5
to
543844b
Compare
At least the type definition in npm_package/odiff.d.ts would need to be changed, so the diffPath parameter is optional. I guess @dmtrKovalenko can say more regarding changes to the odiff.js implementation. |
Firstly thank you so much for your contribution. This is amazing! Yes we definitely need to change the types of the odiff.d.ts file and regenerate readme. Also it would be good to add e2e JavaScript test to cover this functionality and check that it actually works without passing file argument. |
I guess I'd need some help with the |
Yeah I can push something tomorrow |
Thanks, I updated README. Let me know if it sounds OK. |
Oh yeah and after thinking a bit about this: in case there is no output we should not actually write and output buffer so we can save performance a little bit. |
The incorrect equals were used: (==) where (=) was intended.
I made the change to not write to the I moved The difference is quite noticeable. For an 1914x7896 image it's ~862.1 ms when writing output diff and ~340.1 ms without writing. Also, as I understand there was an issue in the case of There was also small issue in the TIFF tests. |
this is okay because the alghoritm of checking antialiased images again calculates the changed pixel so if we already changed the pixel to the 255 255 255 the chance of it being again 255 255 255 is very small and it doesn't really harm the logic |
But I did notice difference is results when specifying output and when it wasn't specified:
|
1234cd7
to
0595d93
Compare
Oh, after clean rebuild the second test hasn't changed locally I reset expect for that test. |
I am against moving the diffOutput to the main function. I am using odiff as a library in osnap, so i am using the diff function directly. With this change I would not be able to access the output anymore. |
You are still able to access output in |
yes, we should keep sticking with a good useful design for the main function as I also want to publish this is a standalone OPAM package at some point. And yes keeping it useful for @eWert-Online is a top priority. So my thought: what if we will make 2 top level wrapper functions like diff and diffWithoutOutput and will keep the api for diff the same but diffWithOutput will pass some kind of flag into the underlying function (yes boolean flag would be fine) and if the flag |
Yes, I know this, but this is not a big deal in a real-world scenario, as the test is a rigorous edge case if we compare 2 images and we know exactly that one pixel was changed and it is not an antialiasing we can not be 100% that any other adjustment pixel around it is not anti-aliasing. That's just my understanding of the anti-aliasing detection alghoritm. There might be some points I miss so would be good to see a real world image which makes the odiff to provide wrong results because of this optimization |
OK, should I revert the changes related to anti-aliasing and image cloning? |
0595d93
to
e672f01
Compare
I updated the code and introduced I had to add Let me know if it looks OK or you like some other approach more. |
@dmtrKovalenko Have you had an occasion to review the updated changes? |
Images can be compared without saving the diff file.
Main.ml
doesn't seem to have tests, so unsure if I should add any.Fixes #64