← Back to team overview

phatch-dev team mailing list archive

Re: GPS action

 

Hi Robin and Nadia,
To be clear: this is the template from which you can start working:
http://bazaar.launchpad.net/~stani/phatch/dev/annotate/head:/phatch/actions/gps.py

Good luck,
Stani

On Thu, Jun 4, 2009 at 1:45 AM, Nadia Alramli <nadiana@xxxxxxxxx> wrote:
> Hi Robin,
>
> I'm also looking forward to working with you. I'll be glad to assist in
> anyway.
>
> Best Regards,
> Nadia
>
> On Wed, Jun 3, 2009 at 10:05 PM, Robin Mills <robin@xxxxxxxxxxxxx> wrote:
>>
>> Stani
>>
>> I'm very happy to go along with all your suggestions and ideas and I'm
>> looking forward to working with Nadia on this.  And one day soon,  Phatch
>> will have a GeoTagger.
>>
>> Robin
>> http://www.clanmills.com
>>
>>
>>
>>
>>
>> On Jun 3, 2009, at 9:17 AM, Stani wrote:
>>
>>> On Fri, May 29, 2009 at 8:52 PM, Robin Mills <robin@xxxxxxxxxxxxx> wrote:
>>>>
>>>> There's code on clanmills.com that does it:
>>>> http://www.clanmills.com/articles/gpsexiftags/gps_py.shtml
>>>>
>>>> It reads GPX files and builds a dictionary called timedict (with <time>
>>>> <position> information).
>>>>
>>>> Then it loops over the images and gets their time stamp (from exif).  It
>>>> finds the closest timestamp (using search) and gets the <position> from
>>>> timedict.  Then it creates the exif GeoTags and writes out the meta
>>>> data.
>>>>
>>>> A couple of comments:
>>>> 1) there's some stuff to deal with time formats and tzinfo - however
>>>> those
>>>> details simply mask the simplicity.
>>>> 2) Would you like some testdata - photos without GeoTags and a GPX file?
>>>>
>>>> Pretty simple, no?  Python is a beautiful language.
>>>
>>>
>>> On Sun, May 31, 2009 at 8:46 PM,  <robin@xxxxxxxxxxxxx> wrote:
>>>>
>>>> However I haven't really made progress with the action script.  I'm kind
>>>> of puzzled by how to interface this into your system.
>>>
>>> Don't worry Nadia will come to rescue you ;-)
>>>
>>>> When my script runs
>>>> I want to know:
>>>>
>>>> 1) path to an gpx file (or directory with one or more gpx files)
>>>> 2) path to an image (or images) to geotag
>>>> 3) tzdiff (seconds) between GPX time (UTC) and Exif time (some local
>>>> time)
>>>>
>>>> I want to avoid read/build timedict for every image and simply that that
>>>> once then apply it to every image.
>>>>
>>>> I looked at several scripts (shadow.py, rename.py and round.py).  And I
>>>> looked at the web documentation.  Then I gave up and thought "Oh, Stani
>>>> will set up the framework in no time at all.  I'll push back on him!"
>>>>
>>>> Robin
>>>
>>> So Robin and Nadia,
>>>
>>> This would be my ideal scenario, feel free to do with it what you
>>> want. The structure of your current script doesn't work for Phatch as
>>> Phatch gets the responsability about looping over the images. The
>>> order of the images in Phatch is alphabetical by full path name. So
>>> this might not necessarily be the time order of the files, but in most
>>> cases it probably will. (Unless there are cameras which count down the
>>> filenumbers.)
>>>
>>> What I would like, is if your script is refactored in a module, which
>>> can land in the phatch/core/lib folder. The module is than imported in
>>> the action. Once it is a module, it will be also more easy to be used
>>> by other python programs ;-) Robin, as you are the author, you decide
>>> on the license, which should be compatible with the GPL3 and any later
>>> version of it (such as GPL3 itself, LGPL3, FreeBSD, public domain, see
>>> for a full list:
>>> http://www.gnu.org/philosophy/license-list.html#GPLCompatibleLicenses).
>>> Mentioning the license is obligatory, otherwise it will block Phatch
>>> from being accepted in Debian.
>>>
>>> I've prepared a template for the gps action which should get you
>>> going: phatch/actions/gps.py. I created it from the rename action, so
>>> please modify any metadata which refers to that (such as email,
>>> __doc__, ...) I am sure Nadia can help you where needed, for example
>>> to look for a nice icon and embed it in the source code.
>>>
>>> The gps module needs to provide a function (eg add_metadata), which
>>> can work on an individual image at the time. Parameters which are not
>>> file specific (such as timedict) should be passed as an argument to
>>> that function. In the action source code we use the cache to store
>>> these parameters. Cache parameters should be prefixed (in this case
>>> with "gps_"), so that there is no namespace collision. I've also
>>> stored timeshift in the cache which normally I prefer not too. As any
>>> field can use variables which are specific to a certain image. However
>>> I don't think someone wants to derive the timeshift from the filename,
>>> so I assume it is safe to put in the cache. It would be better if
>>> Phatch  also allows actions to calculate cache before the loop takes
>>> place and that fields can optionally forbid variables so that their
>>> values can be used for sure in the cache.
>>>
>>> To answer your questions:
>>>>
>>>> 1) path to an gpx file (or directory with one or more gpx files)
>>>
>>> See the ReadFileField (which is defined in
>>> phatch/core/lib/formField.py line 543). We can later specify a
>>> specific gpx field. Do you plan to add more support for other formats
>>> later?
>>>
>>>> 2) path to an image (or images) to geotag
>>>
>>> The gps action will apply the changes to the source file and only to
>>> files saved by the save action of Phatch, if "copy metadata" is
>>> enabled. This allows that the gps action (valid_last=True) can be used
>>> without a save function or can be placed after a save function if you
>>> want to add geo data not in the source but the saved file. Maybe this
>>> is a bit confusing, but with a saved file I refer to the save action.
>>>
>>> You'll get the path from
>>> info = photo.get_info()
>>> info['path']
>>>
>>>> 3) tzdiff (seconds) between GPX time (UTC) and Exif time (some local
>>>> time)
>>>
>>> See integerfield. Although I am wondering if it is not better to
>>> delegate this to a seperate 'timeshift' action:
>>> https://blueprints.launchpad.net/phatch/+spec/time-shift-action
>>>
>>> The template is in rev 629. Please keep all mail correspondance on
>>> phatch-dev (reply all). I hope everything is clear ;-) If you have any
>>> comment, alternative suggestions, ... please let me know. I think
>>> Robin, you can start refactoring your script in the module and Nadia
>>> can already look for an icon, unless Robin has a nice icon already.
>>> The license of the icon should be compatible with the GPL3, so no
>>> creative commons.
>>>
>>> Good luck and go for it!
>>>
>>> Stani
>>>
>>> PS Robin, this is not obligatory for your module, but if possible it
>>> would be nice that during refactoring you switch your module so that
>>> it follows PEP8 (Phatch code and actions should follow PEP8):
>>> http://www.python.org/dev/peps/pep-0008/
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~phatch-dev
>> Post to     : phatch-dev@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~phatch-dev
>> More help   : https://help.launchpad.net/ListHelp
>
>



-- 
Phatch Photo Batch Processor - http://photobatch.stani.be
SPE Python IDE - http://pythonide.stani.be



References