<< More Tutorials
How to read Exif data in json format from an image in Javascript using rethumb?
To read Exif data in json format from an image in Javascript use the following code:
<html>
<head>
<script language = "JavaScript">
window.onload = function()
{
function createCORSRequest(method, url)
{
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr)
{
xhr.open(method, url, true);
}
else if (typeof XDomainRequest !== "undefined")
{
xhr = new XDomainRequest();
xhr.open(method, url);
}
else
{
xhr = null;
}
return xhr;
}
var xhr = createCORSRequest('GET', "http://api.rethumb.com/v1/exif/all/http://images.rethumb.com/image_exif_1.jpg");
if (xhr)
{
xhr.send();
xhr.onload = function()
{
document.getElementById('pre1').innerHTML = xhr.responseText;
};
xhr.onerror = function()
{
document.getElementById('pre1').innerHTML = 'There was an error!';
};
}
else
{
document.getElementById('pre1').innerHTML = 'CORS not supported';
}
}
</script>
</head>
<body>
<pre id="pre1"></pre>
</body>
</html>
Start using this example now
Use the following commands to get started:
$ git clone https://github.com/rethumb/rethumb-javascript-examples.git
$ cd rethumb-javascript-examples
$ open read-exif-data-in-json.html
More examples using Javascript
How to use rethumb in Javascript?
How to resize an image by width in Javascript using rethumb?
How to resize an image by height in Javascript using rethumb?
How to resize an image by width and height in Javascript using rethumb?
How to create a square thumbnail from an image in Javascript using rethumb?
How to read Exif data in json format from an image in Javascript using rethumb?
How to read GPS coordinates from an image in Javascript using rethumb?
How to convert an image to JPG, GIF, PNG, TIF or WebP in Javascript using rethumb?
How to resize an image to cover any dimensions in Javascript using rethumb?