https://github.com/tableflip/isjpeg
:rainbow: is that file really (probably) a jpeg‽
https://github.com/tableflip/isjpeg
Last synced: about 1 year ago
JSON representation
:rainbow: is that file really (probably) a jpeg‽
- Host: GitHub
- URL: https://github.com/tableflip/isjpeg
- Owner: tableflip
- License: isc
- Created: 2015-07-05T23:13:39.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-05T23:32:53.000Z (almost 11 years ago)
- Last Synced: 2025-03-17T07:38:59.858Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 492 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isjpeg
**is that file really (probably) a jpeg‽**
Check the first 2 bytes of the file header to see if it's a JPEG
For when you just don't trust file extensions anymore.
## Usage
**module**
`npm install isjpeg`
```js
var isJpeg = require('isjpeg')
isJpeg('/path/to/mysterious/file', function (err, jpeg) {
if (err) throw err
if (jpeg) {
console.log('file is totes JPEG.')
} else {
console.log('ceci n\'est pas une JPEG.')
}
})
```
**command line**
`npm install -g isjpeg`
```sh
isjpeg ~/Pictures/
/Users/oli/Pictures/MagrittePipe.jpg is JPEG
```
## References
- http://www.mikekunz.com/image_file_header.html
- http://stackoverflow.com/questions/772388/c-sharp-how-can-i-test-a-file-is-a-jpeg
- https://github.com/threatstack/libmagic/blob/master/magic/Magdir/jpeg#L12