Tool for querying, setting and correcting orientation of JPEG files in node.js.
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", "dest.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) {
}
npm install jpegorientation-lwip
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)
Automatically rotate the image to the correct "TopLeft" (orientation=1) and save the orientation data in the Exif headers.
jpeg.autoRotate(source, destination, callback);
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);