GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Extracting location data from images to generate QR codes?

Hi. Is there a good way to extract geo data from images to generate QR codes? I would very much appreciate any help with a script, that makes those QR codes/files with their associated file names, maybe even in some kind of batch mode. I'm not sure, which external application is needed, that also supports command line functionality, but maybe there is some free software that could be used for that task. I suppose, Opus itself has no native QR support yet. Any ideas?

A quick hack.

Get a copy of wget.exe (e.g. here), install it, and adjust the path to the exe in the script in line var exeWget....

The script loops through all selected files and generates .png images next to the original files. Might need and can get some tweaks. Uses the services of http://goqr.me and thus requires an internet connection.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fsu = DOpus.FSUtil();
    var exeWget = fsu.Resolve('/bin\\wgetx32\\wget.exe');

    cmd.deselect = false;
    cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput();

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        var fileMeta = item.metadata;
        if (fileMeta != 'image') continue;

        var lat = fileMeta.image.latitude;
        var lon = fileMeta.image.longitude;
        var alt = fileMeta.image.altitude;

        if (typeof lat != 'number') lat = 0;
        if (typeof lon != 'number') lon = 0;
        if (typeof alt != 'number') alt = 0;

        var cmdLine = exeWget + ' -O ' +
            '"' + item + '.png" ' +
            '"' +
            'http://api.qrserver.com/v1/create-qr-code/?color=000000&bgcolor=FFFFFF&data=geo:' +
            lat + ',' + lon + ',' + alt +
            '&qzone=1&margin=0&size=800x800&ecc=L' +
            '"';

        DOpus.Output(cmdLine);
        cmd.RunCommand(cmdLine);

    }
}

GenerateGeoQrOnline.dcf (5.0 KB)

4 Likes

Hi lxp, great work! As far as i see in a quick test, it works perfectly, aside from the fact, that some of those QR apps can't handle the format. But another QR app could manage to open the coordinates. We will have to make a few tests still, but it looks very promising. Thanks a lot! I will report back, if i have more questions.

:+1: :beers: :beers: