JSPM

jpegorientation

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q28913F

Tool for getting, setting and rotating jpeg images based on Exif rotation information

Package Exports

  • jpegorientation

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jpegorientation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-jpegorientation v1.0.0

Tool for querying, setting and correcting orientation of JPEG files in node.js.

Basic Usage

Get the orientation for an image file:

var jpeg = require("jpegorientation");
jpeg.orientation("IMG_0001.jpg", function(err, orientation) {
    console.log(jpeg.orientationToString(orientation)); // --> "TopLeft"
}

Auto Rotate an image:

var jpeg = require("jpegorientation");
jpeg.autoRotate("IMG_0001.jpg", function(err) {
    
}

Manually set the Exif data for a files orientation (does not actually rotate, just modifies the metadata):

var jpeg = require("jpegorientation");
jpeg.orientation("IMG_0001.jpg", 5, function(err, orientation) {
    
}

Installation

npm install jpegorientation

API Overview

Get or Set JPEG orientation EXIF data

Gets or sets the "Orientation" flag in the specified JPEG's EXIF data section. This requires the EXIF section to be defined in the JPEG files.

jpeg.orientation(source, [newOrientationValue], callback);

note: This does NOT rotate the image, only changes the data in the EXIF header of the image (See autoRotate)

Auto Rotate

Automatically rotate the image to the correct "TopLeft" (orientation=1) and save the orientation data in the Exif headers.

jpeg.autoRotate(source, destination, callback);

Orientation to String

Returns a friendly string describing the orientation. Return value is position for X then Y of the image. (e.g. TopLeft, RightBottom)

jpeg.orientationToString(orientationValue);