X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fsave%2FExifSaver.java;fp=tim%2Fprune%2Fsave%2FExifSaver.java;h=1e597201d5f2842197531159ec3452f542fb428c;hb=5625a1abadb5f2ca5f017fe7dbda1d5141cb637b;hp=0000000000000000000000000000000000000000;hpb=23959e65a6a0d581e657b07186d18b7a1ac5afeb;p=GpsPrune.git diff --git a/tim/prune/save/ExifSaver.java b/tim/prune/save/ExifSaver.java new file mode 100644 index 0000000..1e59720 --- /dev/null +++ b/tim/prune/save/ExifSaver.java @@ -0,0 +1,366 @@ +package tim.prune.save; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +import tim.prune.ExternalTools; +import tim.prune.I18nManager; +import tim.prune.data.Altitude; +import tim.prune.data.Coordinate; +import tim.prune.data.DataPoint; +import tim.prune.data.Photo; +import tim.prune.data.PhotoList; +import tim.prune.data.PhotoStatus; + +/** + * Class to call Exiftool to save coordinate information in jpg files + */ +public class ExifSaver implements Runnable +{ + private Frame _parentFrame = null; + private JDialog _dialog = null; + private JCheckBox _overwriteCheckbox = null; + private JProgressBar _progressBar = null; + private PhotoTableModel _photoTableModel = null; + + + // To preserve timestamps of file use parameter -P + // To overwrite file (careful!) use parameter -overwrite_original_in_place + + // To read all GPS tags, use -GPS:All + // To delete all GPS tags, use -GPS:All= + + // To set Altitude, use -GPSAltitude= and -GPSAltitudeRef= + // To set Latitude, use -GPSLatitude= and -GPSLatitudeRef= + + // To delete all tags with overwrite: exiftool -P -overwrite_original_in_place -GPS:All= + + // To set altitude with overwrite: exiftool -P -overwrite_original_in_place -GPSAltitude=1234 -GPSAltitudeRef='Above Sea Level' + // (setting altitude ref to 0 doesn't work) + // To set latitude with overwrite: exiftool -P -overwrite_original_in_place -GPSLatitude='12 34 56.78' -GPSLatitudeRef=N + // (latitude as space-separated deg min sec, reference as either N or S) + // Same for longitude, reference E or W + + + /** + * Constructor + * @param inParentFrame parent frame + */ + public ExifSaver(Frame inParentFrame) + { + _parentFrame = inParentFrame; + } + + + /** + * Save exif information to all photos in the list + * whose coordinate information has changed since loading + * @param inPhotoList list of photos to save + */ + public boolean saveExifInformation(PhotoList inPhotoList) + { + // Check if external exif tool can be called + boolean exifToolInstalled = ExternalTools.isExiftoolInstalled(); + if (!exifToolInstalled) + { + // show warning + int answer = JOptionPane.showConfirmDialog(_dialog, I18nManager.getText("dialog.saveexif.noexiftool"), + I18nManager.getText("dialog.saveexif.title"), + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + if (answer == JOptionPane.NO_OPTION || answer == JOptionPane.CLOSED_OPTION) + { + return false; + } + } + // Make model and add all photos to it + _photoTableModel = new PhotoTableModel(inPhotoList.getNumPhotos()); + for (int i=0; i