/simple-exiftool

simple-exiftool

Primary LanguageJavaScriptOtherNOASSERTION

Build Status

exiftool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files.

This npm package is a simple wrapper for exiftool, you can extract metadata / meta information from media files easily. Like; video duration, image resolution etc.

You can see complete list of supported media files from here including but not limited to jpg, png, gif, mp4, mov, 3gp, pdf.

  • simple-exiftool requires Node v4+

Quick Installation

  • OS X:
brew update
brew install exiftool
npm install simple-exiftool --save
  • Ubuntu:
sudo apt-get update
sudo apt-get install libimage-exiftool-perl
npm install simple-exiftool --save

Usage

const Exif = require("simple-exiftool");
Exif(source, [settings], callback);

// Default settings are
// {
// 		binary: "exiftool",
//		args: ["-json", "-n"]
// }
// 
// -json argument can not be overriden, since this module parse outputs of exiftool with JSON.parse

###1. Passing single media file path

const Exif = require("simple-exiftool");

Exif("/x/y/image.jpg", (error, metadata) => {
	
	if (error) {
        // handle error
	}
	console.log(metadata);
});

###2. Passing array of media files path

const Exif = require("simple-exiftool");

Exif(["/x/yimage.jpg", "/a/bmovie.mp4"], (error, metadataArray) => {

	if (error) {
        // handle error
	}
	console.log(metadataArray[0], metadataArray[1]);
});

###3. Passing binary data

const Exif = require("simple-exiftool");
const Fs = require("fs");

Fs.readFile("/x/y/image.jpg", (error, binaryData) => {

	if (error) {
        // handle error
	}

	Exif(binaryData, (error, metada) => {

		if (error) {
            // handle error
		}
		console.log(metada);
	});
});

###4. Exiftool binary path and extra arguments

const Exif = require("simple-exiftool");

Exif("/x/y/image.jpg", {binary: "exiftool2", args:["-json", "-s"]}, (error, metadataArray) => {

	if (error) {
        // handle error
	}
	console.log(metadataArray[0], metadataArray[1]);
});