Permalink
Browse files

Update the readme.

Adding an example for getImagePreviews(). Switched the links to the
proper markdown syntax. Split up the examples to make them more readable.
  • Loading branch information...
1 parent e6ce7bf commit 656926c601115a4da95f8fa8ef0426574b69fba4 @drewish drewish committed May 21, 2012
Showing with 35 additions and 11 deletions.
  1. +35 −11 README.md
View
@@ -1,11 +1,17 @@
-##Exiv2
+#Exiv2
-Exiv2 is a native c++ extension for node.js that provides asynchronous support for reading & writing image metadata via Exiv2 (http://www.exiv2.org).
+Exiv2 is a native c++ extension for [node.js](http://nodejs.org/) that provides
+asynchronous support for reading & writing image metadata via
+[Exiv2 library](http://www.exiv2.org).
## Dependencies
-Needs Exiv2, see http://www.exiv2.org/download.html.
+To build this addon you'll need the Exiv2 library and headers, see
+[their download page](http://www.exiv2.org/download.html) for more information.
+
+The tests are written using [Mocha](https://github.com/visionmedia/mocha) and
+[Should](https://github.com/visionmedia/should.js).
## Installation Instructions
@@ -20,28 +26,46 @@ Install the module with npm:
## Sample Usage
+### Read tags:
+
var ex = require('exiv2');
ex.getImageTags('./photo.jpg', function(err, tags) {
- if (err) {
- console.log(err);
- } else {
- console.log(tags);
-
console.log("DateTime: " + tags["Exif.Image.DateTime"]);
console.log("DateTimeOriginal: " + tags["Exif.Photo.DateTimeOriginal"]);
- }
});
- ex.setImageTags('./photo.jpg', { "Exif.Photo.UserComment" : "Some Comment..", "Exif.Canon.OwnerName" : "My Camera"}, function(err){
+### Load preview images:
+
+ var ex = require('exiv2')
+ , fs = require('fs');
+
+ ex.getImagePreviews('./photo.jpg', function(err, previews) {
+ // Display information about the previews.
+ console.log(previews);
+
+ // Or you can save them--though you'll probably want to check the MIME
+ // type before picking an extension.
+ fs.writeFile('preview.jpg', previews[0].data);
+ });
+
+### Write tags:
+
+ var ex = require('exiv2')
+
+ var newTags = {
+ "Exif.Photo.UserComment" : "Some Comment..",
+ "Exif.Canon.OwnerName" : "My Camera"
+ };
+ ex.setImageTags('./photo.jpg', , function(err){
if (err) {
console.log(err);
} else {
console.log("setImageTags complete..");
}
});
-See `example/simple.js`.
+Take a look at the `examples/` and `test/` directories for more.
email: dberesford at gmail
twitter: @dberesford

0 comments on commit 656926c

Please sign in to comment.