ImageInfo: reading image metadata (EXIF) with JavaScript
Written by on August 25th, 2008 in Uncategorized.
Jacob Seidelin finishes up his binary meme with a post on reading image metadata with JavaScript via a library that groks EXIF data.
It tries to detect the format of the image file and then reads the header and pulls out information about dimensions and color depth among other things. If the EXIF data library is included, it will also gather any EXIF tags from JPEG files.
-
-
-
-
// URL of the image (must be on the same domain!)
-
var file = “prettypicture.jpg”;
-
-
// define your own callback function
-
function mycallback() {
-
// either call the ImageInfo.getAllFields([file]) function which returns an object holding all the info
-
alert(
-
“All info about this file: “ + ImageInfo.getAllFields(file).toSource()
-
);
-
-
// or call ImageInfo.getField([file], [field]) to get a specific field
-
alert(
-
“Format: “ + ImageInfo.getField(file, “format”) + “, dimensions : “ + ImageInfo.getField(file, “width”) + “x” + ImageInfo.getField(file, “height”)
-
);
-
}
-
-
// finally, load the data
-
ImageInfo.loadInfo(file, mycallback);
-
ImageInfo, this library, was inspired by the App Engine app IMG2JSON.
Source: Ajaxian » Front Page
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/374206788/imageinfo-reading-image-metadata-exif-with-javascript