use EXIF date for date field

Viewing 7 reply threads
  • Author
    Posts
  • May 15, 2026 at 11:17 AM #54120

    FrAnksch
    Participant

    Can anybody give me a script that reads the EXIF date of a photo (used in field “photo”) and puts this date to an separate field “date”?

    I want the entries to be ordered by the date of the photos, that are used in the records.

    THABK YOU!

    May 16, 2026 at 8:50 PM #54131

    Daniel Leu
    Participant

    Following field script should do the trick. It assumes that the field name is photo. Don’t forget to set the return type of the field script to date.

    
    function First_Photo_Date() {
        // set field name according to your form
        var photo_id = form.getFieldNamed('photo').getId();
    
        // get attached photos
        const photos = record.getFieldValue(photo_id);
    
        // get first photo's date
        const photoExif = photos[0].getExifData(photos[0]);
        const photoDate = photoExif['DateTimeOriginal'];
    
        // handle Exif date format
        const [datePart, timePart] = photoDate.split(" ");
        const [year, month, day] = datePart.split(":").map(Number);
        const [hour, minute, second] = timePart.split(":").map(Number);
    
        // create date object
        const date = new Date(year, month - 1, day, hour, minute, second);
        
        return date;
    }
    
    First_Photo_Date();
    

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    May 18, 2026 at 10:38 PM #54138

    FrAnksch
    Participant

    Thank you so much for your help, Daniel!

    I copied your script into a script-field “EXIF-date” and used the fields “photo” as source and “date” as target.

    Unfortunately I get the following error:

    EXIFdate: TypeError: photos[0].getExifData is not a function. (In ‘photos[0].getExifData(photos[0])’, ‘photos[0].getExifData’ is undefined), line:(null)

    My photo has definitely EXIF data.

    Am I doing something wrong or is there anything with the code?

    btw: I´m on TF5 on iOS 26.5 and macOS Tahoe 26.2 (if this is relevant)

    Thank you!

    • This reply was modified 3 weeks, 5 days ago by FrAnksch.
    May 19, 2026 at 9:25 AM #54140

    Daniel Leu
    Participant

    Oh, my apologies. Tap Forms 5 doesn’t expose the photo metadata, so this script won’t be able to help you. Unfortunately, I don’t have a solution for you either.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    May 19, 2026 at 9:36 AM #54141

    FrAnksch
    Participant

    No Problem, but thanks again for your efforts!
    I also just realized that photos, that I save back to camera roll from Tap Forms, are without EXIF data.
    So is this a problem of TF 5 or of TF in general. Would “TF Pro” work and handle EXIF?

    Thanks

    • This reply was modified 3 weeks, 5 days ago by FrAnksch.
    May 19, 2026 at 11:21 AM #54143

    Daniel Leu
    Participant

    My script works with Tap Forms Pro. Here’s an example using my script showing just the EXIF data of an iPhone image:

    5/19/26, 11:19:12 AM / new form / First photo date
    {
        "WhiteBalance": 0,
        "PixelYDimension": 640,
        "LensMake": "Apple",
        "OffsetTimeOriginal": "-07:00",
        "MeteringMode": 3,
        "ColorSpace": 1,
        "LensModel": "iPhone 13 Pro back triple camera 5.7mm f/1.5",
        "DateTimeDigitized": "2026:05:16 20:00:32",
        "ExposureProgram": 2,
        "OffsetTimeDigitized": "-07:00",
        "ExifVersion": [
            2,
            3,
            2
        ],
        "SubsecTimeDigitized": "392",
        "ExposureBiasValue": 0,
        "ISOSpeedRatings": [
            100
        ],
        "LensSpecification": [
            1.5700000524520874,
            9,
            1.5,
            2.799999952316284
        ],
        "Flash": 16,
        "SubsecTime": "392",
        "CompositeImage": 2,
        "DigitalZoomRatio": 3,
        "SceneType": 1,
        "ApertureValue": 1.1699250021066825,
        "BrightnessValue": 2.820906607251797,
        "DateTimeOriginal": "2026:05:16 20:00:32",
        "FocalLength": 5.7,
        "ExposureMode": 0,
        "SensingMethod": 2,
        "FNumber": 1.5,
        "OffsetTime": "-07:00",
        "PixelXDimension": 480,
        "ShutterSpeedValue": 5.906515543357788,
        "FocalLenIn35mmFilm": 77,
        "SubjectArea": [
            1685,
            1265,
            747,
            735
        ],
        "SubsecTimeOriginal": "392",
        "ExposureTime": 0.016666666666666666
    }
    

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    May 20, 2026 at 12:09 AM #54149

    Brendan
    Keymaster

    Hi Frank,

    Yes, as Daniel has demonstrated, Tap Forms Pro does support EXIF data in images.

    Thanks for helping Daniel!

    Brendan

    May 23, 2026 at 4:22 AM #54167

    FrAnksch
    Participant

    Thanks for confirming. Now I´ll have to consider to change….

Viewing 7 reply threads

You must be logged in to reply to this topic.