danm/image-hash

How work with RequireJS?

Closed this issue · 1 comments

I want use this image-hash with RequireJS.
in my html code:

<script data-main="imagehash" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script> <script> require(['config'], function () { imageHash('http://sample.com/1.jpg', 16, true, (error, data) => { if (error) throw error; console.log(data); }); }); </script>

and in my config.js:
const { imageHash } = require('image-hash');
requirejs.config({
baseUrl: 'node_modules/image-hash/lib/',
paths: {
imageHash: 'node_modules/image-hash/lib/imageHash.js'
}
})

but its not working.

danm commented

image-hash will only work with NodeJS and will not work in the browser.