Search code examples
exif

jquery.exif not load exif data from displayed photo


I cant get exif data from displayed image address

by click on photo You should see the exif data.

var someCallback = function(e) {
    $('#cameraModel').val(e.Model);
    $('#aperture').val(e.FNumber);
    $('#created').val(e.DateTime);
    $('#taken').val(e.DateTimeOriginal);
    $('#copyright').val(e.Copyright);
    $('#description').val(e.ImageDescription);
    $('#artist').val(e.Artist);
    $('#latitude').val(e.GPSLatitude[2]);
    $('#longitude').val(e.GPSLongitude[2]);
    //Uncomment the line below to examine the
    //EXIF object in console to read other values
    //console.log(e);
}

$('#fdd').on('click', function (e) {
    alert($(this).attr("src"));
    $(this).fileExif(someCallback);
});

please help... jsfiddle


Solution

  • From the fiddle, you're trying to use the fileExif method from https://github.com/sanisoft/jQuery-fileExif. You have several problems here:

    • You did not load the library in your fiddle (hence I had to guess which library you tried to use. Hint: read the console log, a message like Uncaught TypeError: Object [object Object] has no method 'fileExif' means you're missing code or trying the call on the wrong object)

    • That library cannot be loaded into a fiddle because it uses document.write. You can remove this code from the plugin to get it to work in a fiddle; it's only needed for IE:

    document.write(
        "<script type='text/vbscript'>\r\n"
        + "Function IEBinary_getByteAt(strBinary, iOffset)\r\n"
        + " IEBinary_getByteAt = AscB(MidB(strBinary,iOffset+1,1))\r\n"
        + "End Function\r\n"
        + "Function IEBinary_getLength(strBinary)\r\n"
        + " IEBinary_getLength = LenB(strBinary)\r\n"
        + "End Function\r\n"
        + "</script>\r\n"
    );