Skip to content
Tool for getting, setting and rotating jpeg images based on Exif rotation information
C++ JavaScript Python
Find file
Latest commit 44d70e0 Jun 13, 2014 Jeremy Condon Updated installation documentataion to include GraphicsMagick require…
…ment

README.md

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

This package depends on Node GM which requires Graphics Magick to be installed (Most system package managers have GraphicsMagick). Although ImageMagick can be used with "GM", this module is not implemented to support ImageMagick, only GraphicsMagick.

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);
Something went wrong with that request. Please try again.