Comments (9)
This is the same issues as with Taylor in #66. Use the latest version of phash.js straight from GitHub. Just copy and paste it over the one in your node_modules
directory. When you do that it will work:
Hillary: cAjc7i6AH1r
Hillary (scribble): e0kL7a0k9hi
Distance: 0.3125
Diff: 0.2898695136417556
I'll release it tonight. Sit tight.
from jimp.
Thanks... Just testing...
I plan to use distance (because it's a value can be pre-calculated and saved to DB, and to check for image duplication I just need a hamming distance, for every DB image).
To use diff() I should call it once for each DB image, right? I'm afraid it should be too slow (db is expected to reach ~750K images...). Correct me if wrong, please...
One more thing, about hashes lengths: you said it is due to chance... But so I can't expect hashes lengths to be all the same? But if they do differ, how do I calculate a distance???
Thanks for your attention!
from jimp.
While calculating hashes for my images, I get:
my-app/node_modules/jpeg-js/lib/decoder.js:323
throw "marker was not found";
^
marker was not found
[21:20:35] [nodemon] app crashed - waiting for file changes before starting...
and my app crashes... Probably the image was empty, but Jimp should try to catch these errors, to avoid crashing, right? I (Jimp user) could catch these exceptions, too, but...
from jimp.
I think your strategy regarding distance and diffing sounds good.
About exceptions: Errors in Jimp are handled by throwing exceptions (unless a Node-style callback is passed). Yes, that will crash your app but I'm delegating that to you to catch. Most are a straight-forward case of a wrong argument being passed to a method so I'm surprised at the error you got.
To compute the hammering distance, you would be better off converting the base 64 hash to binary and padding to 64 digits with leading zeros as necessary. You can get the binary quite easily with: image.hash(2);
Compute the hammering distance against those.
I'm planning on padding each the hashes with leading 0s as necessary for this reason.
from jimp.
I've also just made a fix where hashes will be returned with leading zeros. This will make it easier to compare binary hashes stored in a DB for hammering distance.
from jimp.
This night I did realize why 11... :-)
Correct me if wrong: to encode a byte in base64 you need 6 bits (2^6 = 64). Then to encode 64 bits you need 11 base64 bytes (64 / 6 = 10.6...) (i.e.: you need 10 full base64 bytes, plus one, that you'll use for the last 4 bits... Hence, no need for padding, it's automatic...
Please don't tell me I'm completely wrong... :-D
from jimp.
The padding is in case the first bit is not 1:
var white = new Jimp(256, 256, 0xFFFFFFFF);
var black = new Jimp(256, 256, 0x000000FF);
console.log("W: " + white.hash(2));
console.log("B: " + black.hash(2));
// Output:
// W: 1000000000000000000000000000000000000000000000000000000000000000
// B: 0000000000000000000000000000000000000000000000000000000000000000
console.log("W: " + white.hash(64));
console.log("B: " + black.hash(64));
// Output:
// W: 80000000000
// B: 00000000000
from jimp.
Perfect...
Marco Solari
System Analyst, Software Engineer and IT Consultant at Koinè Sistemi Torino
On 10 November 2015 at 10:28, Oliver Moran [email protected] wrote:
The padding is in case is if the first bit is not 1:
var white = new Jimp(256, 256, 0xFFFFFFFF);
var black = new Jimp(256, 256, 0x000000FF);console.log("W: " + white.hash(2));
console.log("B: " + black.hash(2));// Output:
// W: 1000000000000000000000000000000000000000000000000000000000000000
// B: 0000000000000000000000000000000000000000000000000000000000000000console.log("W: " + white.hash(64));
console.log("B: " + black.hash(64));// Output:
// W: 80000000000
// B: 00000000000—
Reply to this email directly or view it on GitHub
#67 (comment).
from jimp.
Already in NPM ?
Marco Solari
System Analyst, Software Engineer and IT Consultant at Koinè Sistemi Torino
On 10 November 2015 at 10:33, Marco Solari [email protected] wrote:
Perfect...
Marco Solari
System Analyst, Software Engineer and IT Consultant at Koinè Sistemi TorinoOn 10 November 2015 at 10:28, Oliver Moran [email protected]
wrote:The padding is in case is if the first bit is not 1:
var white = new Jimp(256, 256, 0xFFFFFFFF);
var black = new Jimp(256, 256, 0x000000FF);console.log("W: " + white.hash(2));
console.log("B: " + black.hash(2));// Output:
// W: 1000000000000000000000000000000000000000000000000000000000000000
// B: 0000000000000000000000000000000000000000000000000000000000000000console.log("W: " + white.hash(64));
console.log("B: " + black.hash(64));// Output:
// W: 80000000000
// B: 00000000000—
Reply to this email directly or view it on GitHub
#67 (comment).
from jimp.
Related Issues (20)
- unrecognised content at end of stream
- Suggest adding Otsu's threshold algorithm
- No matter what, "Mime must be a string"
- Error reading arraybuffer in production environment HOT 1
- Share some examples of how to use it.(Multi page tiff from multiple images)
- @jimp/png won't work with @jimp/custom HOT 1
- .brightness() method does not affect brightness
- Upgrade dependancy version of xml2js HOT 1
- Save to specific width and height in inches HOT 1
- Jimp.decoders is undefined in browser with webpack and typescript HOT 1
- ERR_PNPM_NO_MATCHING_VERSION No matching version found for @jimp/plugin-scale@^0.22.12
- zlib_bindings problem when used in Vite with Typescript HOT 1
- Do anyone can run jimp in latest reactjs project? HOT 1
- Unable to get it working in a Vue project. HOT 4
- [BUG] Error when using ES Modules with Jimp HOT 7
- Cannot load fonts in Web Worker HOT 1
- Japanese characters not able to write and render image
- Unable to install jimp library through npm bcz of vulnerabilities checks HOT 3
- Update phin version HOT 9
- Reading base64 image from a Buffer is slow HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jimp.