I wrote a HTML page who calls thmbnail.ws to generate thumbnail for given URL (in this code it's a map from gmap), this is my code :
$.ajax({
url: 'https://cors-anywhere.herokuapp.com/http://api.thumbnail.ws/api/API_KEY/thumbnail/get?url=http://maps.google.com/?q=36.82,10.17&width=800',
crossDomain: true,
headers: {'X-Requested-With': 'XMLHttpRequest'},
contentType: "image/jpeg",
success: function (data) {
console.log('Thumbnail Call OK');
console.log('Data Type : ' + typeof(data));
$('#map2').html('Image : <img src="data:image/jpeg;base64,' + data + '" />');
}
});
This is the execution result :
I thought the response is base64 encoded data, so i've tried to put data into an img tag (in div#map2) but no way : As you can see I have strange chars in the image area ! Debugger says result is image/jpeg, if I click on "Response" tab I have this :
And when I clik "here" I have the good image :
I can't figure out the right data type and how to display it in my page !