Code Monkey home page Code Monkey logo

Comments (16)

ccpandhare avatar ccpandhare commented on July 20, 2024

That's a really awesome idea!
But in this case, the problem is a bit different.

I just tried this:

var r = savePixels(pixels, options.format, {quality: 100});
...

That is, explicitly asking save-pixels to save in high quality.
After that, there was no deterioration as we can see above at all.

But that created a new problem. The build failed.
One unit test failed.
Screenshot of failed test

As you can see in the screenshot, the two values which tape says are "not equal" are actually equal.

I even tried equating them in JS. Still unequal. I assure you, they are equal. Because of this, I had to remove the {quality: 100} parameter. And hence we are facing that issue.

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

Why do you think the reason could be?
For two strings to be unequal but seem equal when printed?
Different encoding?
Or What could it possibly be? I am just out of thoughts :/

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

Sorry, this somehow skipped me. Thanks for your suggestion about the String() but that didnt work. Based on StackOverflow answers, I have tried string.trim(), that didn't work either.

Also, this works:
string1.substring(0,string1.length-25) == string2.substring(0,string2.length-25) //true

If 25 is replaced with any number less than 25, the above returns false.

These are the two strings:
(When I compare them on http://www.textdiff.com/ It says that there's nothing common in the two strings! It also shows similar results -- the '25' thing)

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIABAAEAMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hp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GiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APxfr/Kc/wC/gKACgAoA/wD/2Q==

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

Aha! I looked really carefully -- the first string ends with:

APxnr/Kc/wC/gKACgAoA/wD/2Q==

The second ends with:

APxfr/Kc/wC/gKACgAoA/wD/2Q==

Notice: APxnr vs. APxfr -- !!

just one character off.

https://gist.github.com/jywarren/fdb5294effe01b908245700a38adc057/revisions

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

If you re-encode again, does it stay APxfr?

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

Wow those are exceptionally great observation skills there, I must say!

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

No, re-encoding doesn't change anything, I tried.
I think the method I am using for testing this isn't ideal.
I doubly-invert a DataURL and equate two DataURL strings.

I should probably use a different sort of comparison. Like one with a threshold.
I don't know why doubly inverting a DataURL would give a slightly different result when generated in High Quality. Do you know any articles which would help me identify which part of a DataURL/Image Binary contain what information

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

Thanks for the update! I will do that.

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

The issue that we are facing, of the unequal DataURLs, could it be the result of the lossy JPEG compression?

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

Turns out I am right! I converted that image to PNG and now it works! What should be done now? I still think that comparing with a threshold should should be implemented.

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

from image-sequencer.

ccpandhare avatar ccpandhare commented on July 20, 2024

The module you mentioned npm:image-diff is pretty heavy. I am not sure we should use it.
Maybe I can write a lightweight library for that myself.

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

There were a few others, no? And we don't need to include it in the library itself; it could just be included in the test suite and under devDependencies.

https://github.com/publiclab/image-sequencer/blob/master/CONTRIBUTING.md#module-candidates -- had several diff modules. I'd like to open this issue and take slow steps in this direction; not urgent!

from image-sequencer.

jywarren avatar jywarren commented on July 20, 2024

oops, ok -- #83!

from image-sequencer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.