Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fisker/jpeg-buffer-orientation
Get orientation from a JPEG file.
https://github.com/fisker/jpeg-buffer-orientation
Last synced: 6 days ago
JSON representation
Get orientation from a JPEG file.
- Host: GitHub
- URL: https://github.com/fisker/jpeg-buffer-orientation
- Owner: fisker
- License: mit
- Created: 2019-03-20T06:59:00.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T19:27:24.000Z (7 months ago)
- Last Synced: 2024-04-23T11:28:16.206Z (7 months ago)
- Language: JavaScript
- Homepage: https://fisker.github.io/jpeg-buffer-orientation/
- Size: 38.2 MB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# jpeg-buffer-orientation
[![gzip size](http://img.badgesize.io/https://unpkg.com/jpeg-buffer-orientation/dist/index.min.mjs?compression=gzip&style=flat-square)](http://img.badgesize.io/https://unpkg.com/jpeg-buffer-orientation/dist/index.min.mjs)
[![Travis](https://img.shields.io/travis/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://travis-ci.org/fisker/jpeg-buffer-orientation)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f1c92423809b450e871e4812581f8fe6)](https://app.codacy.com/app/fisker/jpeg-buffer-orientation?utm_source=github.com&utm_medium=referral&utm_content=fisker/jpeg-buffer-orientation&utm_campaign=Badge_Grade_Settings)
[![Coveralls github](https://img.shields.io/coveralls/github/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://coveralls.io/github/fisker/jpeg-buffer-orientation)[![devDependencies](https://img.shields.io/david/dev/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://david-dm.org/fisker/jpeg-buffer-orientation)
[![Issues](http://img.shields.io/github/issues/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://github.com/fisker/jpeg-buffer-orientation/issues)
[![Issues](https://img.shields.io/github/issues-pr/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://github.com/fisker/jpeg-buffer-orientation/pulls)
[![GitHub last commit](https://img.shields.io/github/last-commit/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://github.com/fisker/jpeg-buffer-orientation/commits)
[![GitHub Release Date](https://img.shields.io/github/release-date/fisker/jpeg-buffer-orientation.svg?style=flat-square)](https://github.com/fisker/jpeg-buffer-orientation/releases)[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![MIT license](https://img.shields.io/github/license/fisker/jpeg-buffer-orientation.svg?style=flat-square)](http://opensource.org/licenses/MIT)> Get orientation of JPEG file.
## Install
```sh
yarn add --dev jpeg-buffer-orientation
```## Usage
in browser
```html
import getOrientation from 'https://unpkg.com/jpeg-buffer-orientation?module'
const response = await fetch('./foo.jpg')
const buffer = await response.arrayBuffer()
const orientation = getOrientation(buffer)console.log('orientation', orientation)
```
[demo](https://fisker.github.com/jpeg-buffer-orientation)
in browser (legacy)
```html
const buffer = myJpegFile.arrayBuffer()
console.log(getOrientation(buffer))```
in node (not recommended)
```js
import fs from 'node:fs/promises'
import getOrientation from 'jpeg-buffer-orientation'const myJpegFile = new URL('./foo.jpg', import.meta.url)
const {buffer} = await fs.readFile(myJpegFile)
const orientation = getOrientation(buffer)
console.log('orientation', orientation)
```## API
getJpegOrientation(buffer)
- buffer
type: `ArrayBuffer`
- @returns
type: `Number|undefined`
## FYI
this package is design for use in browser, not optimized for node.
1. accept `Buffer` instead of `ArrayBuffer` should be easier to use.
2. instead of reading the whole image, just reading head maybe better.