PlasmaPower / phash-image

phash for images
MIT License
55 stars 6 forks source link

Accept a readable stream as input #7

Closed Sparragus closed 9 years ago

Sparragus commented 9 years ago

It'd be very efficient and useful to accept a readable stream as an input to the phash function.

I mean this: phash(readableStream, callback)

Here's an example on why that would be a good idea:

var fileURL = 'http://i.imgur.com/0UiD1CK.jpg'

// fetch an image from the web
http.get(fileURL, function (response) {
  // pass the response (which is an image and also a readable stream) to phash
  phash(response)
  .then(hash => (
    // get hash measure hamming distance with another hash.
    // do something else...
  ))
})

Is this possible? I would be happy to implement this if someone points me in the right direction.

lovell commented 9 years ago

Hi Richard, I believe the underlying libphash API lacks support for stream or buffer based input.

The addition of stream-based input would be easier to implement and might be more appropriate for https://github.com/mgmtio/dhash-image, should its image hashing algorithm meet your needs.

Sparragus commented 9 years ago

I was afraid of that. Still, thanks for your reply. I'll check out dhash. If it works better or just as well as phash, I might switch and try to implement streams.

Cheers!