Skip to content

Commit

Permalink
Merge pull request #2 from denisnazarov/use-npm
Browse files Browse the repository at this point in the history
Refactor to use npm modules instead of git submodules.
  • Loading branch information
artfwo committed Nov 6, 2014
2 parents c005893 + 5c4ed3c commit dfbaaf4
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 354 deletions.
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

67 changes: 29 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,39 @@ blockhash-js
This is a perceptual image hash calculation tool based on algorithm descibed in
Block Mean Value Based Image Perceptual Hashing by Bian Yang, Fan Gu and Xiamu Niu.

Usage
Installation
-----

This script requires png.js and jpgjs, which are linked as
git submodules. To fetch them run:
This module is installed via npm:

git submodule init
git submodule update
```
$ npm install blockhash-js
```

Or you can download them directly (but the tests require the submodules):

* https://github.com/devongovett/png.js
* https://github.com/notmasteryet/jpgjs

To use the script in a page, add `<script src="blockhash.js"/>` to
your page and call `blockhash(src, bits, method, callback)`, where
Use in the browser
-----
To use this library in the browser, you can build it with Browserify
with something like `browserify index.js --standalone blockhashjs >
blockhash.js`

Include it and `zlib.js` on your page:
```html
<!DOCTYPE html>
<html>
<head>
<title>Blockhash</title>
</head>
<body>
<script src="node_modules/png-js/zlib.js"></script>
<script src="blockhash.js"></script>
<script>
var blockhash = blockhashjs.blockhash;
</script>
</body>
</html>
```

Call `blockhash(src, bits, method, callback)`, where
`src` is an image URL, `bits` is the number of bits in a row, `method`
is a number 1-4 (see below), and `callback` is a function with
`(error, result)` signature. On success, `result` will be array of
Expand All @@ -35,32 +52,6 @@ matches on any image size. The quick ones are only advisable when the
image width and height are an even multiple of the number of blocks
used.


Example
-------

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<script src="png.js/zlib.js"></script>
<script src="png.js/png.js"></script>
<script src="jpgjs/jpg.js"></script>

<script src="blockhash.js"></script>

<script>
var bits = 16;
blockhash('test.png', bits, 1, function(error, result) {
console.log('hash: ' + result);
});
</script>
</head>
<body>
</body>
</html>

License
-------

Expand Down
264 changes: 0 additions & 264 deletions blockhash.js

This file was deleted.

Loading

0 comments on commit dfbaaf4

Please sign in to comment.