ExifRead

Read image files metadata and provide Exif tags.

python · Common Scripts

Source

import demistomock as demisto  # noqa: F401
import exifread
from CommonServerPython import *  # noqa: F401


def get_exif_tags(file_entry_id):
    res = demisto.getFilePath(file_entry_id)
    f = open(res["path"], "rb")

    tags = exifread.process_file(f)  # pylint: disable=E1101
    arr = []
    for tag in tags:
        arr.append({"tag": str(tag), "value": str(tags[tag])})

    md = tableToMarkdown("Exif Tags", arr)

    demisto.results(
        {
            "ContentsFormat": formats["json"],
            "Type": entryTypes["note"],
            "Contents": {"Exif": arr},
            "HumanReadable": md,
            "EntryContext": {"Exif": arr},
        }
    )


def main():
    file_entry_id = demisto.args()["EntryID"]
    get_exif_tags(file_entry_id)


# python2 uses __builtin__ python3 uses builtins
if __name__ == "__builtin__" or __name__ == "builtins":
    main()

README

Reads an image file’s metadata and provides Exif tags.

Script Data


Name Description
Script Type python
Tags Utility

Inputs


Argument Name Description
EntryID The entry ID of the image file.

Outputs


Path Description Type
Exif.tag The Exif tag name. string
Exif.value The Exif tag value. string