commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: [sanselan] Removing GPS tags problem
Date Sat, 01 Dec 2012 20:57:17 GMT

Good Evening Piotr //assuming TiffOutputSet is a representation of the meta data acquired
from your Tiff file//once you *acquired*  the output set from JpegMetadata
TiffOutputSet outputSet = exif.getOutputSet(); //then setting both the lat and long as doubles
will effectively 0 out the GPS attributes...double longitude=0.0;double latitude=0.0;outputSet.setGPSInDegrees(longitude,
latitude);
http://commons.apache.org/imaging/xref-test/org/apache/sanselan/sampleUsage/WriteExifMetadataExample.html
does this not work for you?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.

 > Date: Sat, 1 Dec 2012 18:08:11 +0100
> Subject: [sanselan] Removing GPS tags problem
> From: ptrczajka@gmail.com
> To: user@commons.apache.org
> 
> Hi,
> I have a problem with removing gps data from photo.
> It's works  but also other tags unrelated with gps are removed
> 
> code  :
> 
> 
>  public void removeExifTag(File jpegImageFile, File dst) throws
> IOException, ImageReadException,
> 
>               ImageWriteException {
> OutputStream os = null;
> try {
>     TiffOutputSet outputSet = null;
> 
>     // note that metadata might be null if no metadata is found.
>     IImageMetadata metadata = Imaging.getMetadata(
> jpegImageFile);
>     JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
>     if (null != jpegMetadata)
>       {
>         // note that exif might be null if no Exif metadata is found.
>         TiffImageMetadata exif = jpegMetadata.getExif();
> 
>         if (null != exif)
>           {
>             // TiffImageMetadata class is immutable (read-only).
>             // TiffOutputSet class represents the Exif data to write.
>             //
>             // Usually, we want to update existing Exif metadata by
>             // changing
>             // the values of a few fields, or adding a field.
>             // In these cases, it is easiest to use getOutputSet() to
>             // start with a "copy" of the fields read from the image.
>             outputSet = exif.getOutputSet();
>         }
>     }
> 
>     if (null == outputSet) {
>         // file does not contain any exif metadata. We don't need to
>         // update the file; just copy it.
>         IoUtils.copyFileNio(jpegImageFile, dst);
>         return;
>     }
> 
>     {
>         // Example of how to remove a single tag/field.
>         // There are two ways to do this.
> 
>         // Option 1: brute force
>         // Note that this approach is crude: Exif data is organized in
>         // directories. The same tag/field may appear in more than one
>         // directory, and have different meanings in each.
> 
>       // outputSet.removeField(ExifTagConstants.EXIF_TAG_GPSINFO);
> 
>         // Option 2: precision
>         // We know the exact directory the tag should appear in, in this
>         // case the "exif" directory.
>         // One complicating factor is that in some cases, manufacturers
>         // will place the same tag in different directories.
>         // To learn which directory a tag appears in, either refer to
>         // the constants in ExifTagConstants.java or go to Phil Harvey's
>         // EXIF website.
> 
>      TiffOutputDirectory gpsDirectory = outputSet.getGPSDirectory();    //
> <-----------------------------------
>         if (null != gpsDirectory)
>         {
>             gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE);
>             gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
> 
>         }
>     }
> 
>     os = new FileOutputStream(dst);
>     os = new BufferedOutputStream(os);
> 
>     new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
>             outputSet);
> 
>     os.close();
>     os = null;
> } finally {
>     if (os != null)
>         try {
>             os.close();
>         } catch (IOException e) {
> 
>         }
> }
> }
> 
> I want to remove only gps position information from photo
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message