Reading EXIF data from image



  • Hey. I'm trying this useful javascript for reading EXIF data from my image:
    http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html

    However I'm not able to pass the image argument into the script from QML. Just keep getting warnings like this:

    simple_one.qml:30: TypeError: Result of expression 'EXIF.getTag' [undefined] is not a function.

    Here is how I try to do it:

    @import "exif.js" as EXIF
    ...
    Image {
    id: image1
    x: 231
    y: 120
    width: 196
    height: 125
    fillMode: Image.Stretch
    source: "photos/12092009401.jpg"
    }

    Text {
    id: text1
    x: 165
    y: 366
    width: 80
    height: 20
    color: "#ffffff"
    text: EXIF.getTag("photos/12092009401.jpg", "Model")
    font.pointSize: 20
    }
    @

    Seems that the argument of image should be passed to the exif.js in some other way. Any ideas what I'm doing wrong here?



  • The values exported from exif.js are put on a global object named EXIF (incidentally the same as your import). In a normal browser environment you would access them by using EXIF.Tags, EXIF.getTag etc.
    But in QML javascript globals are imported into their own namespace (in your case also EXIF).
    So anything declared on the global context inside the exif.js is available on that additional EXIF object.

    So - to make complicated things short:

    To access your functions you have to call @EXIF.EXIF.getTag@.

    You could also change exif.js and remove the closure and have all the functions and constants directly on the global context.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.