You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sanselan-dev@incubator.apache.org by Charles Matthew Chen <ch...@gmail.com> on 2008/02/01 02:09:54 UTC
Re: Sanselan GPS Latitude / Longitude EXIF Writing
Hi Arnaud,
I've just built another release of Sanselan, version 0.90. It
contains some convenience functions to make reading and writing GPS
metadata a bit easier. You can get it here:
http://fightingquaker.com/sanselan/
Exif GPS info includes at a minimum four tags: longitude, latitude,
longitude ref and latitude ref. Also, they need to be added to the
GPS directory, not the exif directory. The longitude and latitude
fields are unusual; they are represented by a trio of rational numbers
representing degrees, minutes and seconds (as in your code).
The convenience functions for reading GPS info are demonstrated in
the MetadataExample class:
http://fightingquaker.com/sanselan/MetadataExample.java
"""
TiffImageMetadata exifMetadata = jpegMetadata.getExif();
TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
String gpsDescription = gpsInfo.toString();
double longitude = gpsInfo.getLongitudeAsDegreesEast();
double latitude = gpsInfo.getLatitudeAsDegreesNorth();
"""
The convenience functions for writing GPS info are demonstrated in
WriteExifMetadataExample class:
// New York City
double longitude = -74.0; // 74 degrees W (in Degrees East)
double latitude = 40 + 43/60.0; // 40 degrees N (in Degrees North)
outputSet.setGPSInDegrees(longitude, latitude);
I've cc'd the sanselan-dev mailing list.
Charles.
On Jan 31, 2008 5:46 AM, Arnaud Mondit <nt...@gmail.com> wrote:
> Hello.
>
> I am currently using your Sanselan library (fantastic work btw !) to write
> GPS metadata into JPEG files. I initially have two double values
> representing latitude and longitude from my software.
>
> Following your writer example, I was unable to use the
> TiffOutputField.create() method since GPS longitude and latitude tags seems
> to have an incompatible length ( != 1). So I tried to use directly the
> TiffOutputField constructor, defining myself the byte[] with the writedata()
> method of the rational field type.
>
> But my code below doesn't seem to write the metadata to the file (the
> longitude tag is missing) :
>
> FieldTypeRational fieldtype = TiffFieldTypeConstants.FIELD_TYPE_RATIONAL;
>
> RationalNumber ratio[] = {new RationalNumber(7,1), new RationalNumber(24,1),
> new RationalNumber(5660,100)};
>
> TiffOutputField gpsinfo = new
> TiffOutputField(TiffConstants.GPS_TAG_GPS_LATITUDE,fieldtype,
> 3,fieldtype.writeData(ratio, outputSet.byteOrder) );
>
> TiffOutputDirectory exifDirectory = outputSet.getOrCreateExifDirectory();
>
> exifDirectory.add(gpsinfo);
>
> Do you know how to correctly create a GPS latitude / longitude tag into the
> metadata of a file using your library.
>
> Thanks.
>
> Best Regards.
>
> Arnaud Mondit
>