Get orientation from EXIF of image file. Supports both Browser and Node.js
Installations
npm install get-orientation
Score
97.9
Supply Chain
99.5
Quality
75.3
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS, UMD
Min. Node Version
Typescript Support
Yes
Node Version
8.16.1
NPM Version
6.11.3
Statistics
117 Stars
148 Commits
3 Forks
3 Watching
31 Branches
3 Contributors
Updated on 10 May 2024
Bundle Size
2.31 kB
Minified
0.99 kB
Minified + Gzipped
Languages
TypeScript (79.93%)
JavaScript (13.24%)
HTML (6.84%)
Total Downloads
Cumulative downloads
Total Downloads
105,946,622
Last day
-17.2%
14,669
Compared to previous day
Last week
2.5%
101,338
Compared to previous week
Last month
2.2%
444,928
Compared to previous month
Last year
-52.2%
7,469,074
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
get-orientation
Get orientation from EXIF of image file. Supports both Browser and Server (Node.js) environment.
get-orientation
has fast, efficient built-in EXIF parser.
Built-in EXIF Parser is stream-based, and uses small memory footprint.
Also, Compatibility is the key. get-orientation
was tested with 50+ test images.
Sponsor
- CATCH - 캐치패션 - 세상 쉬운 명품 직구 - We're hiring!
Demo
https://mooyoul.github.io/get-orientation/
Why?
Most Browsers don't rotate images automatically.
Hmm... How about adaption stats of CSS3 Image Orientation?
Well. Good luck.
To rotate image by its orientation, you'll have to make a EXIF parser or install heavy EXIF related libraries.
That's why i made this.
Compatibility
get-orientation works in major environments, including IE 10.
Tested Platforms (Node.js)
Platform | Environment | Build | Compatibility |
---|---|---|---|
macOS Mojave | Node.js 4 | Default | Compatible |
macOS Mojave | Node.js 6 | Default | Compatible |
Linux Ubuntu Trusty | Node.js 6 | Default | Compatible |
macOS Mojave | Node.js 8 | Default | Compatible |
Linux Ubuntu Trusty | Node.js 10 | Default | Compatible |
macOS Mojave | Node.js 10 | Default | Compatible |
Tested Platforms (Browser)
Platform | Environment | Build | Compatibility |
---|---|---|---|
Windows XP/7 | ~ IE 9 | N/A | Incompatible due to missing FileReader/DataView support |
Windows 7 | IE 10 | Browser/ES5 | Compatible, Requires Promise and WeakMap polyfill |
Windows 7 | IE 11 | Browser/ES5 | Compatible, Requires Promise polyfill |
Windows 10 | IE 11 | Browser/ES5 | Compatible, Requires Promise polyfill |
macOS Mojave | Chrome 74 | Browser/ES6 (Default) | Compatible |
macOS Mojave | Safari | Browser/ES6 (Default) | Compatible |
macOS Mojave | Safari TP | Browser/ES6 (Default) | Compatible |
macOS Mojave | Firefox Developer Edition 67 | Browser/ES6 (Default) | Compatible |
macOS Mojave | Firefox 65 | Browser/ES6 (Default) | Compatible |
iOS 12.0.1 | Safari | Browser/ES6 (Default) | Compatible |
Android 5 | Mobile Chrome 74 | Browser/ES6 (Default) | Compatible |
Install
from NPM
1$ npm install get-orientation
from unpkg
1<!-- ES6 Target Build (default) --> 2<script type="text/javascript" src="https://unpkg.com/get-orientation/browser"></script> 3 4<!-- ES5 Target Build (for Compat, requires Promise, WeakMap polyfill --> 5<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.6.5/core.min.js"></script> 6<script type="text/javascript" src="https://unpkg.com/get-orientation/browser.es5"></script>
Supported Image Format
-
JPEG/JFIF
-
JPEG/EXIF
-
TIFF/EXIF
Usage
Node.js
1 2import * as fs from "fs"; 3import { getOrientation } from "get-orientation"; 4 5// using Readable File Stream as input 6const stream = fs.createReadStream(imageFilePath); 7const orientation = await getOrientation(stream); 8 9// using Buffer as input 10const bufFile = fs.readFileSync(imageFilePath); 11const orientation = await getOrientation(bufFile); 12 13// using HTTP Response body as input 14import axios from "axios"; 15const response = await axios({ url, responseType: "stream" }); 16const orientation = await getOrientation(response.data); 17 18 19// using Stream interface directly 20import { EXIFOrientationParser, Orientation } from "get-orientation"; 21 22const parser = new EXIFOrientationParser(); 23parser.on("orientation", (orientation: Orientation) => { 24 console.log("got orientation: ", orientation); 25}); 26 27fs.createReadStream(imageFilePath).pipe(parser);
Browser
1import { getOrientation } from "get-orientation/browser"; 2 3async function onFileChanged() { 4 const orientation = await getOrientation(fileInput.files[0]); 5 // do stuff... 6}
IMPORTANT NOTE
The ES5 target browser build does not include any Polyfills like Promise/A+. For example, To use this library from Microsoft Internet Explorer 11, You'll have to polyfill Promise.
API (Node.js)
getOrientation(input: Buffer | ReadableStream)
=> Promise<Orientation>
returns Orientation of given image.
If image is non-jpeg image, or non-image, getOrientation
will return Orientation.TOP_LEFT (Horizontal - Default value).
new EXIFOrientationParser()
=> WritableStream
returns a parser stream instance that implements WritableStream interface.
Please note that EXIFOrientationParser won't emit any orientation
event if stream doesn't have any Orientation tags.
also, Stream will be closed without any errors.
For example, Using non-EXIF images, non-JPEG images as input won't emit a orientation
event.
Stream Events
orientation
emitted after parsing orientation.
API (Browser)
getOrientation(input: ArrayBuffer | Blob | File)
=> Promise<Orientation>
returns Orientation of given image.
If image is non-jpeg image, or non-image, getOrientation
will return Orientation.TOP_LEFT (Horizontal - Default value).
Types
Orientation
1enum Orientation { 2 TOP_LEFT = 1, // Horizontal (Default) 3 TOP_RIGHT = 2, // Mirror Horizontal 4 BOTTOM_RIGHT = 3, // Rotate 180 5 BOTTOM_LEFT = 4, // Mirror vertical 6 LEFT_TOP = 5, // Mirror horizontal and rotate 270 CW 7 RIGHT_TOP = 6, // Rotate 90 CW 8 RIGHT_BOTTOM = 7, // Mirror horizontal and rotate 90 CW 9 LEFT_BOTTOM = 8, // Rotate 270 CW 10}
Changelog
See CHANGELOG.
Testing
1$ npm run test
get-orientation uses BrowserStack for compatibility testing.
Build
1$ npm run build
Related
- mooyoul/node-webpinfo - Strongly typed, Stream based WebP Container Parser
License
See full license on mooyoul.mit-license.org
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/mooyoul/get-orientation/main.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/mooyoul/get-orientation/main.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Reason
53 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-2h3h-q99f-3fhc
- Warn: Project is vulnerable to: GHSA-gmw6-94gg-2rc2
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg
- Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-hj9c-8jmm-8c52
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.5
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More