Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Reading EXIF data from image

    QML and Qt Quick
    2
    2
    5990
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      strekazoid last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • M
        mutaphysis last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post