Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
jpeg-autorotate
Advanced tools
Rotates JPEG images based on EXIF orientation.
This tool applies the right orientation to a JPEG image, based on its EXIF tag. More precisely, it:
1
in the Orientation
EXIF tag (this is the default orientation)PixelXDimension
and PixelYDimension
EXIF valuesIt may be useful, if:
More information about EXIF orientation: EXIF Orientation Handling Is a Ghetto
Install with npm:
$ npm install jpeg-autorotate --global
# --global isn't required if you plan to use the node module
# Rotates a single image
$ jpeg-autorotate /Users/johan/IMG_1234.jpg
# Rotates a set of images
$ jpeg-autorotate /Users/johan/images/IMG_*.jpg
The tool is available as a Node module. It will load the image, apply the rotation, and return the binary data as a Buffer, allowing you to:
var jpegautorotate = require('jpeg-autorotate');
var options = {quality: 85};
jpegautorotate.rotate('/Users/johan/IMG_1234.jpg', options, function(error, buffer, orientation)
{
if (error)
{
console.log('An error occurred when rotating the file: ' + error.message);
return;
}
console.log('Orientation was: ' + orientation);
// ...
// Do whatever you need with the buffer
// ...
});
The error
object returned in the callback contains a readable message
, but also a code
for better error handling. Available codes are the following:
var jo = require('jpeg-autorotate');
jo.errors.read_file; // File could not be opened
jo.errors.read_exif; // EXIF data could not be read
jo.errors.no_orientation; // No orientation tag was found
jo.errors.unknown_orientation; // The orientation tag is unknown
jo.errors.correct_orientation; // The image orientation is already correct
jo.errors.rotate_file; // An error occurred when rotating the image
Sample usage:
var jo = require('jpeg-autorotate');
jo.rotate('/image.jpg', function(error, buffer, orientation)
{
if (error && error.code === jo.errors.correct_orientation)
{
console.log('The orientation of this image is already correct!');
}
});
The following options are available.
Option | Context | Default value | Description |
---|---|---|---|
quality | CLI, module | 100 | Quality of the JPEG - Uncompressed by default, so the resulting image may be bigger than the original one |
jobs | CLI | 10 | Max number of concurrent processes, when loading several images |
To use options with the CLI:
$ jpeg-autorotate /image.jpg --jobs=100 --quality=85
This project uses semver.
Version | Date | Notes |
---|---|---|
1.0.0 | 2016-03-21 | Initial version |
This project is released under the MIT License.
FAQs
Rotate JPEG images based on EXIF orientation
The npm package jpeg-autorotate receives a total of 9,132 weekly downloads. As such, jpeg-autorotate popularity was classified as popular.
We found that jpeg-autorotate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.