lundi 26 février 2007

Write GPS data on your photos with Exiftool

Exiftool is a Windows/Mac command-line app (or a muti-plateform Perl librairy) to read and write EXIF metadatas on certain file types.

In the following I will use .jpg files from my camera and the Windows .exe version of Exiftool that I will control in a DOS shell.

Want to see some EXIF metadata in your picture ?

$ exiftool mypicture.jpg

Want to extract the precise date and time when this picture was taken ?

$ exiftool -CreateDate mypicture.jpg
( Returns something "2007:02:10 21:19:43")

Want to write your picture was on the Eastern part of Greenwich meridian ?

$ exiftool -GPSLongitudeRef="E" mypicture.jpg

Want to write the exact the longitude value ?

$ exiftool -GPSLongitude="7.422809" mypicture.jpg

Want to write your picture is in the northern latitudes ?

$ exiftool -GPSLatitudeRef="N" mypicture.jpg

and give the exact latitude value ?

$ exiftool -GPSLatitude="48.419973" mypicture.jpg

Obviously you can combine the four tags above in just one line.

You can check everything went well with another exiftool mypicture.jpg (warning: if the app. doesn't understand what to do it didn't return me any error message by default ).

More informations about the GPS tags can be found here.

With this Free Software GPL command-line version it's now easy to integrate geolacalisation capabilities in a Python script for example.

I can upload my pictures on Flickr and they will show on the Flick maps but I still need to use the geocoding bookmarklet if I want to add the geotagged tags and the google maps.

PS: -n option gives you the latitude/longitude in the decimal form when reading these tags
PS: Python also have a nice similar library but I didnt' succeed to write GPS data with it,

mercredi 21 février 2007

[Python] Callback examples with FTP

From the wikipedia article:

In computer programming, a callback is executable code that is passed as an argument to other code. It allows a lower-level software layer to call a function defined in a higher-level layer.

Usually, the higher-level code starts by calling a function within the lower-level code passing to it a pointer or handle to another function. While the lower-level function executes, it may call the passed-in function any number of times to perform some subtask. In another scenario, the lower-level function registers the passed-in function as a handler that is to be called asynchronously by the lower-level at a later time in reaction to something.

Two examples with the FTP module of Python:

from ftplib import FTP

ftp = FTP("the_host")
ftp.login('ftpuser', 'ftppass')

# To obtain the list of files in a variable (not just the standard output) :


# To download the file :

file = open("myfile.exe", 'wb')
ftp.retrbinary("RETR myfile.exe",file.write)

mardi 20 février 2007

[Python] How to get the output from os.system() into a variable ?

A quick solution using popen :

import os
print result

where command is your command (expl. on windows: dir,ipconfig,...)

If you expect more than a line and want each word in a list:

import os,string

Source of this

samedi 17 février 2007

Clipboard and all-in-one system information for windows

Two useful free software to complete my list of windows utilities :

Ditto is a very useful Open Source clipboard:

- history of text copies, images, screenshots
- enable hot keys, network sync, etc

SIW is a freeware which stands for "System Information for Windows"

- no installation required (can run on a USB key)
- hardware informations, temperature sensors, license keys, process, etc, etc.