Changeset 31168 in osm for applications/editors
- Timestamp:
- 2015-06-01T11:27:52+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java
r31163 r31168 39 39 40 40 if (pane.getValue() != null 41 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 41 && (int) pane.getValue() == JOptionPane.OK_OPTION 42 && dialog.chooser != null) { 42 43 if (dialog.group.isSelected(dialog.all.getModel())) { 43 44 export(MapillaryData.getInstance().getImages()); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
r31166 r31168 2 2 3 3 import java.awt.image.BufferedImage; 4 import java.io.BufferedOutputStream; 4 5 import java.io.File; 6 import java.io.FileOutputStream; 5 7 import java.io.IOException; 8 import java.io.OutputStream; 6 9 import java.util.concurrent.ArrayBlockingQueue; 7 10 8 11 import javax.imageio.ImageIO; 9 12 13 import org.apache.sanselan.ImageReadException; 14 import org.apache.sanselan.ImageWriteException; 15 import org.apache.sanselan.formats.jpeg.exifRewrite.ExifRewriter; 16 import org.apache.sanselan.formats.tiff.constants.GPSTagConstants; 17 import org.apache.sanselan.formats.tiff.constants.TagInfo; 18 import org.apache.sanselan.formats.tiff.constants.TiffDirectoryConstants; 19 import org.apache.sanselan.formats.tiff.constants.TiffFieldTypeConstants; 20 import org.apache.sanselan.formats.tiff.fieldtypes.FieldType; 21 import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory; 22 import org.apache.sanselan.formats.tiff.write.TiffOutputField; 23 import org.apache.sanselan.formats.tiff.write.TiffOutputSet; 10 24 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 11 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 40 54 public void run() { 41 55 monitor.setCustomText("Downloaded 0/" + amount); 42 File outputfile = null;56 File tempFile = null; 43 57 BufferedImage img; 44 58 MapillaryImage mimg = null; … … 48 62 img = queue.take(); 49 63 mimg = queueImages.take(); 50 finalPath = path + "/" + mimg.getKey() + ".jpeg"; 51 outputfile = new File(finalPath); 52 ImageIO.write(img, "jpeg", outputfile); 64 finalPath = path + "/" + mimg.getKey(); 65 tempFile = new File(finalPath + ".tmp"); 66 67 ImageIO.write(img, "jpg", tempFile); 68 69 // Write EXIF tags 70 TiffOutputSet outputSet = new TiffOutputSet(); 71 TiffOutputDirectory exifDirectory = outputSet 72 .getOrCreateGPSDirectory(); 73 FieldType fieldType = TiffFieldTypeConstants.FIELD_TYPE_RATIONAL; 74 TiffOutputField directionref = TiffOutputField.create(GPSTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF, outputSet.byteOrder, "T"); 75 exifDirectory.add(directionref); 76 TiffOutputField direction = TiffOutputField.create( 77 new TagInfo("GPS Img Direction", 17, fieldType , 1, TiffDirectoryConstants.EXIF_DIRECTORY_GPS), outputSet.byteOrder, mimg.getCa()); 78 exifDirectory.add(direction); 79 try { 80 outputSet.setGPSInDegrees(mimg.getLatLon().lon(), mimg 81 .getLatLon().lat()); 82 } catch (ImageWriteException e) { 83 // TODO Auto-generated catch block 84 e.printStackTrace(); 85 } 86 OutputStream os = new BufferedOutputStream( 87 new FileOutputStream(finalPath + ".jpg")); 88 new ExifRewriter().updateExifMetadataLossless(tempFile, os, 89 outputSet); 90 tempFile.delete(); 91 os.close(); 92 53 93 } catch (InterruptedException e1) { 54 94 // TODO Auto-generated catch block 55 95 e1.printStackTrace(); 56 96 } catch (IOException e) { 97 // TODO Auto-generated catch block 98 e.printStackTrace(); 99 } catch (ImageReadException e) { 100 // TODO Auto-generated catch block 101 e.printStackTrace(); 102 } catch (ImageWriteException e) { 57 103 // TODO Auto-generated catch block 58 104 e.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.