diff --git a/AdjustTime.ini b/AdjustTime.ini index c816bc3..04be5eb 100644 --- a/AdjustTime.ini +++ b/AdjustTime.ini @@ -1,6 +1,9 @@ #by AdjustTime -#Sun Jun 26 09:29:35 JST 2016 +#Sun Jun 26 15:08:44 JST 2016 GPX.gpxSplit=ON -GPX.REUSE=OFF -GPX.BASETIME=FILE_UPDATE +IMG.OUTPUT_FOLDER=/media/yuu/public/osm/GPXs/\u7DBE\u702C\u5E02\u5409\u5CA1_20160103 +GPX.REUSE=ON +IMG.SOURCE_FOLDER=/media/yuu/public/osm/GPXs/\u7DBE\u702C\u5E02\u5409\u5CA1_20160103 +GPX.BASETIME=2016-01-03T17\:56\:50 GPX.noFirstNode=ON +IMG.BASE_FILE=S2690001.JPG diff --git a/importPicture/src/AdjustTime.ini b/importPicture/src/AdjustTime.ini index 500ecc0..95624cc 100644 --- a/importPicture/src/AdjustTime.ini +++ b/importPicture/src/AdjustTime.ini @@ -1 +1,5 @@ +#by AdjustTime +#Sun Jun 26 12:44:33 JST 2016 GPX.gpxSplit=ON +GPX.REUSE=OFF +GPX.noFirstNode=ON diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index 849e281..96cf947 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -194,6 +194,7 @@ obj.gpxFiles.add(obj.gpxDir); } + obj.exifBase = (obj.params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME") ? true : false); System.out.println(" - param: number of gpxFiles = '"+ obj.gpxFiles.size() +"'"); System.out.println(" - param: imgDir = '"+ obj.imgDir.getAbsolutePath() +"'"); @@ -214,6 +215,7 @@ public File outDir; public long delta = 0; public boolean exif = false; + public boolean exifBase = false; public ArrayList gpxFiles = new ArrayList<>(); public AppParameters params; public boolean param_GpxSplit = false; diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java b/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java index 65f4bec..55b2bf3 100644 --- a/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java +++ b/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.*; @@ -16,9 +17,6 @@ import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata; import org.apache.commons.imaging.formats.tiff.TiffImageMetadata; import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants; -import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory; -import org.apache.commons.imaging.formats.tiff.write.TiffOutputField; -import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet; /** * 本プログラムのメインクラス @@ -40,7 +38,9 @@ JPanel argsPanel; // パラメータ設定パネル (上部) JScrollPane imageSPane; // スクロールパネル JLabel imageLabel; // 基準時刻画像表示 - JCheckBox exifBase; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする) + ButtonGroup baseTimeGroup; // 基準時刻の指定グループ + JRadioButton exifBase; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする) + JRadioButton fupdateBase; // File更新日時を基準にする/ !(XIF日時を基準にする) JCheckBox noFirstNode; // GPX: セグメントの最初の1ノードは無視する。 {ON | OFF} JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF} JTextArea textArea; // 実行結果表示領域 @@ -188,9 +188,21 @@ arg2_baseTimeImg = new ParameterPanelImageFile("基準時刻画像: ", params.getProperty(AppParameters.IMG_BASE_FILE), arg1_srcFolder); argsPanel.add(arg2_baseTimeImg); - exifBase = new JCheckBox("EXIFの日時を基準にする", false); - exifBase.setEnabled(false); + baseTimeGroup = new ButtonGroup(); + exifBase = new JRadioButton("EXIFの日時を基準にする"); + fupdateBase = new JRadioButton("File更新日時を基準にする"); + baseTimeGroup.add(exifBase); + baseTimeGroup.add(fupdateBase); argsPanel.add(exifBase); + argsPanel.add(fupdateBase); + if (params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME")) { + fupdateBase.setSelected(false); + exifBase.setSelected(true); + } + else { + fupdateBase.setSelected(true); + exifBase.setSelected(false); + } cards[cardNo].add(argsPanel, BorderLayout.CENTER); //--------------------------------------------------------------------- @@ -239,7 +251,7 @@ noFirstNode = new JCheckBox("セグメントの最初の1ノードは無視する。", params.getProperty(AppParameters.GPX_NO_FIRST_NODE).equals("ON")); tmpPanel4a.add(noFirstNode); gpxReuse = new JCheckBox("生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。", params.getProperty(AppParameters.GPX_REUSE).equals("ON")); - gpxReuse.setEnabled(false); + gpxReuse.setEnabled(true); tmpPanel4a.add(gpxReuse); cards[cardNo].add(tmpPanel4a, BorderLayout.CENTER); @@ -393,19 +405,26 @@ long lastModifyTime = timeFile.lastModified(); arg3_basetiome.argField.setText(ImportPicture.dfjp.format(new Date(lastModifyTime))); - try { - ImageMetadata meta = Imaging.getMetadata(timeFile); - if (!(meta instanceof JpegImageMetadata)) { - TiffImageMetadata exif = ((JpegImageMetadata)meta).getExif(); - if (exif != null) { - TiffOutputSet outputSet = exif.getOutputSet(); - TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory(); - TiffOutputField field = exifDir.findField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); - arg3_basetiome.argField.setText(field.toString()); + if (exifBase.isSelected()) { + try { + ImageMetadata meta = Imaging.getMetadata(timeFile); + arg3_basetiome.argField.setText("imageView_Action : 412"); + + JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta; + if (jpegMetadata != null) { + TiffImageMetadata exif = jpegMetadata.getExif(); + if (exif != null) { + String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0]; + lastModifyTime = (new SimpleDateFormat("yyyy:MM:dd HH:mm:ss")).parse(dateTimeOriginal).getTime(); + arg3_basetiome.argField.setText(ImportPicture.dfjp.format(new Date(lastModifyTime))); + } + else { + arg3_basetiome.argField.setText("exif == null"); + } } - } + } + catch (Exception e) {} } - catch (Exception e) {} int size_x = imageSPane.getWidth() - 8; ImageIcon tmpIcon = new ImageIcon(path); @@ -524,6 +543,10 @@ this.params.setProperty(AppParameters.GPX_NO_FIRST_NODE, (noFirstNode.isSelected() ? "ON" : "OFF")); this.params.setProperty(AppParameters.GPX_REUSE, (gpxReuse.isSelected() ? "ON" : "OFF")); + this.params.setProperty(AppParameters.IMG_SOURCE_FOLDER, arg1_srcFolder.getText()); + this.params.setProperty(AppParameters.IMG_BASE_FILE, arg2_baseTimeImg.getText()); + this.params.setProperty(AppParameters.GPX_BASETIME, arg3_basetiome.getText()); + this.params.setProperty(AppParameters.IMG_OUTPUT_FOLDER, arg4_gpxFolder.getText()); try { this.params.store(); }