JavaScript Exif reader (only available in the browser).
npm install @fengyuanchen/exif
<script src="/path/to/exif.js"></script>
Four available usages:
new Exif(HTMLImageElement, options)
new Exif(HTMLImageElement.src, options)
new Exif(File, options)
new Exif(Blob, options)
Example:
<img id="image" src="image.jpg">
var image = document.getElementById('image');
var exif = new Exif(image, {
done: function(tags) {
console.log(tags);
}
});
You may set cropper options with new Exif(image, options)
.
- Type:
Boolean
- Default:
true
Read Exif tags.
- Type:
Boolean
- Default:
true
Read GPS tags.
- Type:
Boolean
- Default:
true
Read interoperability tags.
- Type:
Array
orBoolean
- Default:
['MakerNote', 'UserComment']
Assign the ignored tags. Set false
to disable it.
- Type:
Function
- Default:
null
Read success callback.
new Exif(image, {
done: function(tags) {
console.log(tags);
}
});
- Type:
Function
- Default:
null
Read error callback.
new Exif(image, {
fail: function(message) {
console.log(message);
}
});
If you have to use other global function with the same namespace, just call the Exif.noConflict
static method to revert to it.
<script src="other-exif.js"></script>
<script src="exif.js"></script>
<script>
Exif.noConflict();
// Code that uses other `Exif` can follow here.
</script>
- Chrome (latest 2)
- Firefox (latest 2)
- Internet Explorer 10+
- Opera (latest 2)
- Safari (latest 2)