https://github.com/plotdb/imgtype
https://github.com/plotdb/imgtype
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/plotdb/imgtype
- Owner: plotdb
- Created: 2020-01-24T17:51:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2026-03-20T06:27:38.000Z (2 months ago)
- Last Synced: 2026-03-20T23:02:02.044Z (2 months ago)
- Language: Pug
- Size: 2.43 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# imgtype
Image type Hint.
## Usage
require! <[imgtype]> # only if use in nodejs
imgtype(obj).then ({ext, mime}) -> ... # ext = null if can't figure it out
## Mime mappaing
You can use `imgtype.mime["..."]` to get the mime type for a specific file extension, such as:
imgtype.mime.svg
imgtype.mime.jpg
Supported extensions include:
- `bmp`: `image/bmp`
- `gif`: `image/gif`
- `png`: `image/png`
- `svg`: `image/svg+xml`
- `tif`: `image/tiff`
- `jpg`: `image/jpeg`
## Approach
Image file type can be detected throught the first two bytes of the file:
* TIF
- SU : 49 49
- TU : 4D 4D
* BMP : Qk : 42 4D
* JPG : /9 : FF D8 FF EO ( Starting 2 Byte will always be same)
* PNG : iV : 89 50 4E 47
* GIF : R0 : 47 49 46 38
* SVG
- `