ImageAttributes QML Type

(BETA) Allows storing of additional metadata in JEPG images. More...

Import Statement: import ArcGIS.AppFramework 1.0

Properties

Methods

Detailed Description

The ImageAttributes component is used for reading and writing medadata in JPEG images stored in custom JPEG APPn markers.

The following code sample sets a number of example metadata values, before printing them in the console log.

ImageAttributes {
    id: imageAttributes
    filePath: "~/ArcGIS/Data/Pictures/Esri.jpg"
    Component.onCompleted: {
        imageAttributes.setValue("data.json", {"address":"380 New York Street","name":"ESRI"});
        imageAttributes.setValue("brownfox.txt", "The quick brown fox jumped over the lazy dog.\n");
        imageAttributes.loadValueFromFile("jack.jpg", "~/ArcGIS/Data/Pictures/jack2.jpg");
        let _keys = imageAttributes.keys();
        console.log("imageAttributes.keys: ", JSON.stringify(_keys)); // ["data.json","brownfox.txt","jack.jpg"]
        let data = imageAttributes.value("data.json");
        console.log("typeof(data): ", typeof data); // object
        console.log("data: ", JSON.stringify(data)); // {"address":"380 New York Street","name":"ESRI"}
        let brownfox = imageAttributes.value("brownfox.txt");
        console.log("typeof(brownfox): ", typeof brownfox); // string
        console.log("brownfox: ", JSON.stringify(brownfox)); // "The quick brown fox jumped over the lazy dog.\n"
        let image = imageAttributes.value("jack.jpg");
        console.log(typeof("typeof(image): ", typeof image)); // object
        console.log("image instanceof ArrayBuffer: ", image instanceof ArrayBuffer); // true
        console.log("image.byteLength: ", image.byteLength); // 533643
        let values = imageAttributes.values();
        console.log("imageAttributes.values(): ", JSON.stringify(values)); // {"brownfox.txt":"The quick brown fox jumped over the lazy dog.\n","data.json":{"address":"380 New York Street","name":"ESRI"},"jack.jpg":"blob://imageattributes/jack.jpg"}
        let notExists = imageAttributes.value("notexist.txt");
        console.log("typeof(notExists): ", typeof(notExists)); // undefined
        console.log("notExists: ", JSON.stringify(notExists)); // undefined
        let ok = imageAttributes.saveValueToFile("jack.jpg", "~/ArcGIS/Data/Pictures/Jack2.jpg");
        console.log("imageAttributes.saveValueToFile: ", JSON.stringify(ok)); // true
    }
}

Property Documentation

appMarker : int

This property is reserved for further use.


destFilePath : string

Filepath to where the metadata will be written to.


destFileUrl : url

URL to where the metadata will be written to.


filePath : string

Path to where the metadata will be read from.


fileUrl : url

URL to where the metadata will be read from.


signature : string

This property is reserved for further use.


version : ushort

This property is reserved for further use.


Method Documentation

object keys()

Returns a list of attributes currently stored in the JPEG image.


bool loadValueFromFile(string key, url fileUrl)

Store a file referred to by URL as a binary object attribute in a JPEG image.

The key parameter

The key of the attribute that will store the file.

The fileUrl parameter

The URL of the file that will be stored as an attribute.


bool loadValueFromFile(string key, string filePath)

Store a file referred to by filepath as a binary object attribute in a JPEG image.

The key parameter

The key of the attribute that will store the file.

The filePath parameter

The path of the file that will be stored as an attribute.


remove(qstringlist keys)

Remove a list of metadata attributes from the JPEG image.

The keys parameter

A list of attributes to remove from the image.


remove(string key)

Remove a single attribute from the JPEG image.

The key parameter

The key of the attribute to remove from the image.


removeAll()

Removes all attributes from the JPEG image.


bool saveValueToFile(string key, url fileUrl)

Exports the given attribute to a file at the set URL.

The key parameter

The key of the attribute to export.

The fileUrl parameter

The intended URL of the file to export the attribute to.


bool saveValueToFile(string key, string filePath)

Exports the given attribute to a file at the set filepath.

The key parameter

The key of the attribute to export.

The filePath parameter

The intended path of the file to export the attribute to.


bool setValue(string key, object value)

Update or add an attribute to the JPEG image.

The key parameter

The key of the attribute to add to the JPEG image.

The value parameter

The value of the attribute to add.

See also value().


bool setValues(object values)

Adds a list of attibutes to the JPEG image.

The values parameter

A list of values to set in a JPEG image.

See also values().


object value(string key)

Retrieves the defined attribute's value from the JPEG image.

The key parameter

The key of the attribute to retrieve the value of.

See also setValue().


object values(qstringlist keys)

Retrieves a number of attributes from a JPEG image.

The keys parameter

The list of keys to attributes to retrieve values from.


object values()

Retrieve a full list of values and attributes from a JPEG image.


object values(string key)

Retrieves a single attribute's value from a JPEG image.

The key parameter

The key of the attribute to return the value of.

See also setValues().


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.