Page 1 of 1

Scripting GC - how to get from file name to window?

Posted: Thu Sep 02, 2021 11:03 am
by chrillek
Hi, I'm trying to write a (JavaScript) script to work with the currently selected files in GC. It's simple to get the current selection like so

Code: Select all

var app = Application("GraphicConverter 11");
var sel = app.windows[0].selection()
Now, sel is an array ("list" in AppleScript parlance) containing the file names of the selected images. If I understand the GC script dictionary correctly, almost all methods and properties are bound to the Window object and not accessible if only a file name is available.

How would I go about to (for example) set the property "IPTC credit text" (bound to Window) if all I have is a file name? If somebody knows how to do that in AppleScript, that's fine too – I'll manage to translate that.

Re: Scripting GC - how to get from file name to window?

Posted: Sun Sep 05, 2021 11:33 am
by forum_adm
Hi,

what do you want to script exactly?

Metadata should be changed without opening the file. This avoids recompression.

Thorsten

Re: Scripting GC - how to get from file name to window?

Posted: Mon Sep 13, 2021 10:29 am
by chrillek
This is more an educational then a real project. I figured out how to get at the file's meta data in the mean time (although the documentation is a bit terse on that – that I have to use

Code: Select all

exifInfo['88250002']
(in JavaScript) to get the latitude, took some experimentation).

The idea for the script was reverse geocoding (i.e. fill in the country/city IPTC fields from the GPS EXIF data). As I said, educational, since GC knows how to do that already anyway. I found a way to _get_ the data in node.js, but that is so slow that it's not practical.