Select to view content in your preferred language

How to use QML Extras ExifInfo & FileInfo classes?

1334
2
Jump to solution
01-10-2019 03:30 PM
MarkDeaton
Esri Contributor

As part of a QML QtQuick app I'm working on, I want to retrieve certain photo file metadata: latitude, longitude, and file-create date. To this end, I've tried to use the ExifInfo class in ArcGISExtras 1.1. However, it doesn't seem to be working for me.

When I set ExifInfo.filePath, the resulting ExifInfo.isExifValid is always false, and the gpsLongitude and gpsLatitude properties are always NaN. Not even the undocumented refresh() method seems to do anything. I have verified that the filePath and url properties do change properly after this. I've tried this on Windows 10 and Android 9.

Do you have a sample that might show how to set the file and retrieve its EXIF properties? The doc page sample is lacking a little context.
ExifInfo QML Type | ArcGIS for Developers 

Thanks.

[Edit]

A little trial and error showed me that it works to set ExifInfo.filePath with a value like "c:/photos/photo1.jpg" rather than using a url-style value such as "file:///c:/photos/photo1.jpg", and that setting the url property doesn't work.

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I gave this a try with a photo from my iPhone (attached) and it seems to work for me. Here is what I had (just copied from the API doc pretty much):

// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//


import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISExtras 1.1

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "Untitled16"


    ExifInfo {
        id: exif1
        filePath: "C:/temp/IMG_2776.jpg"
        function logExifMetadata() {
            console.log(
                        "\nFile:              " + exif1.filePath +
                        "\nCreated:           " + exif1.created +
                        "\nIs Exif valid?     " + exif1.isExifValid +
                        "\nExif version:      " + exif1.extendedValue(0x9000) +
                        "\nCamera manuf:      " + exif1.imageValue(0x010F) +
                        "\nCamera model:      " + exif1.imageValue(0x0110) +
                        "\nGPS latitude:      " + exif1.gpsLatitude +
                        "\nGPS longitude:     " + exif1.gpsLongitude +
                        "\nGPS altitude:      " + exif1.gpsAltitude +
                        "\nGPS speed:         " + exif1.gpsValue(0x000D) +
                        "\nAll image tags:    " + exif1.imageTags +
                        "\nAll extended tags: " + exif1.extendedTags +
                        "\nAll GPS tags:      " + exif1.gpsTags);
        }
    }

    Button {
        onClicked: exif1.logExifMetadata()
    }
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And here is the output:

File: C:/temp/IMG_2776.jpg
Created: Wed Jan 23 14:42:26 2019 GMT-0600
Is Exif valid? true
Exif version:  
Camera manuf: Apple
Camera model: iPhone XR
GPS latitude: 19.699025
GPS longitude: -155.46133333333333
GPS altitude: 34.08290480371253
GPS speed: 0
All image tags: 271,272,274,282,283,296,305,306,322,323
All extended tags: 33434,33437,34850,34855,36864,36867,36868,37121,37377,37378,37379,37380,37383,37385,37386,37396,37500,37521,37522,40960,40962,40963,41495,41729,41986,41987,41989,41990,42034,42035,42036
All GPS tags: 1,2,3,4,5,6,7,12,13,16,17,23,24,29,31

Perhaps there is something up with the images you are using, or maybe the formats being used aren't working correctly with the ExifInfo class.

FYI, we missed in the doc that this class inherits FileInfo, so we will be fixing that up. All properties/methods on FileInfo are therefore also available on ExifInfo

View solution in original post

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

I gave this a try with a photo from my iPhone (attached) and it seems to work for me. Here is what I had (just copied from the API doc pretty much):

// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//


import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISExtras 1.1

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "Untitled16"


    ExifInfo {
        id: exif1
        filePath: "C:/temp/IMG_2776.jpg"
        function logExifMetadata() {
            console.log(
                        "\nFile:              " + exif1.filePath +
                        "\nCreated:           " + exif1.created +
                        "\nIs Exif valid?     " + exif1.isExifValid +
                        "\nExif version:      " + exif1.extendedValue(0x9000) +
                        "\nCamera manuf:      " + exif1.imageValue(0x010F) +
                        "\nCamera model:      " + exif1.imageValue(0x0110) +
                        "\nGPS latitude:      " + exif1.gpsLatitude +
                        "\nGPS longitude:     " + exif1.gpsLongitude +
                        "\nGPS altitude:      " + exif1.gpsAltitude +
                        "\nGPS speed:         " + exif1.gpsValue(0x000D) +
                        "\nAll image tags:    " + exif1.imageTags +
                        "\nAll extended tags: " + exif1.extendedTags +
                        "\nAll GPS tags:      " + exif1.gpsTags);
        }
    }

    Button {
        onClicked: exif1.logExifMetadata()
    }
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And here is the output:

File: C:/temp/IMG_2776.jpg
Created: Wed Jan 23 14:42:26 2019 GMT-0600
Is Exif valid? true
Exif version:  
Camera manuf: Apple
Camera model: iPhone XR
GPS latitude: 19.699025
GPS longitude: -155.46133333333333
GPS altitude: 34.08290480371253
GPS speed: 0
All image tags: 271,272,274,282,283,296,305,306,322,323
All extended tags: 33434,33437,34850,34855,36864,36867,36868,37121,37377,37378,37379,37380,37383,37385,37386,37396,37500,37521,37522,40960,40962,40963,41495,41729,41986,41987,41989,41990,42034,42035,42036
All GPS tags: 1,2,3,4,5,6,7,12,13,16,17,23,24,29,31

Perhaps there is something up with the images you are using, or maybe the formats being used aren't working correctly with the ExifInfo class.

FYI, we missed in the doc that this class inherits FileInfo, so we will be fixing that up. All properties/methods on FileInfo are therefore also available on ExifInfo

0 Kudos
MarkDeaton
Esri Contributor

Thanks, Lucas. As I mentioned in the edit to my original message, I did get it to work in much the same way as you've illustrated. The API doc could use your updates, as it was the filePath parameter that finally made it work for me; that's missing from the Esri doc example and properties list.

--Mark

0 Kudos