source:
josm/trunk/lib/metadata-extractor-2.3.1-nosun.diff@
1193
Last change on this file since 1193 was 392, checked in by , 17 years ago | |
---|---|
File size: 3.9 KB |
-
src/com/drew/imaging/jpeg/JpegMetadataReader.java
commit f1681c3697d5cc51c282af35557b88f65b76e8d0 Author: Gabriel Ebner <ge@gabrielebner.at> Date: Mon Oct 15 19:31:06 2007 +0200 Remove all references to the com.sun.image.codec.jpeg package. diff --git a/src/com/drew/imaging/jpeg/JpegMetadataReader.java b/src/com/drew/imaging/jpeg/JpegMetadataReader.java index aeacaa3..3fc08a7 100644
a b import com.drew.metadata.exif.ExifReader; 25 25 import com.drew.metadata.iptc.IptcReader; 26 26 import com.drew.metadata.jpeg.JpegCommentReader; 27 27 import com.drew.metadata.jpeg.JpegReader; 28 import com.sun.image.codec.jpeg.JPEGDecodeParam;29 28 30 29 import java.io.File; 31 30 import java.io.IOException; … … public class JpegMetadataReader 89 88 return metadata; 90 89 } 91 90 92 public static Metadata readMetadata(JPEGDecodeParam decodeParam)93 {94 final Metadata metadata = new Metadata();95 96 /* We should only really be seeing Exif in _data[0]... the 2D array exists97 * because markers can theoretically appear multiple times in the file.98 */99 // TODO test this method100 byte[][] exifSegment = decodeParam.getMarkerData(JPEGDecodeParam.APP1_MARKER);101 if (exifSegment != null && exifSegment[0].length>0) {102 new ExifReader(exifSegment[0]).extract(metadata);103 }104 105 // similarly, use only the first IPTC segment106 byte[][] iptcSegment = decodeParam.getMarkerData(JPEGDecodeParam.APPD_MARKER);107 if (iptcSegment != null && iptcSegment[0].length>0) {108 new IptcReader(iptcSegment[0]).extract(metadata);109 }110 111 // NOTE: Unable to utilise JpegReader for the SOF0 frame here, as the decodeParam doesn't contain the byte[]112 113 // similarly, use only the first Jpeg Comment segment114 byte[][] jpegCommentSegment = decodeParam.getMarkerData(JPEGDecodeParam.COMMENT_MARKER);115 if (jpegCommentSegment != null && jpegCommentSegment[0].length>0) {116 new JpegCommentReader(jpegCommentSegment[0]).extract(metadata);117 }118 119 return metadata;120 }121 122 91 private JpegMetadataReader() 123 92 { 124 93 } -
src/com/drew/metadata/SampleUsage.java
diff --git a/src/com/drew/metadata/SampleUsage.java b/src/com/drew/metadata/SampleUsage.java index e1b1a3b..a28dafa 100644
a b import com.drew.imaging.jpeg.JpegProcessingException; 21 21 import com.drew.imaging.jpeg.JpegSegmentReader; 22 22 import com.drew.metadata.exif.ExifReader; 23 23 import com.drew.metadata.iptc.IptcReader; 24 import com.sun.image.codec.jpeg.JPEGCodec;25 import com.sun.image.codec.jpeg.JPEGDecodeParam;26 import com.sun.image.codec.jpeg.JPEGImageDecoder;27 24 28 25 import java.awt.image.BufferedImage; 29 26 import java.io.File; … … public class SampleUsage 87 84 } catch (JpegProcessingException jpe) { 88 85 System.err.println("error 3a"); 89 86 } 90 91 // Approach 492 // This approach is the slowest, because it decodes the Jpeg image. Of93 // course you now have a decoded image to play with. In some instances94 // this will be most appropriate.95 try {96 JPEGImageDecoder jpegDecoder = JPEGCodec.createJPEGDecoder(new FileInputStream(jpegFile));97 BufferedImage image = jpegDecoder.decodeAsBufferedImage();98 // now you can use the image99 JPEGDecodeParam decodeParam = jpegDecoder.getJPEGDecodeParam();100 Metadata metadata = JpegMetadataReader.readMetadata(decodeParam);101 printImageTags(4, metadata);102 } catch (FileNotFoundException e) {103 System.err.println("error 4a");104 } catch (IOException e) {105 System.err.println("error 4b");106 }107 87 } 108 88 109 89 private void printImageTags(int approachCount, Metadata metadata)
Note:
See TracBrowser
for help on using the repository browser.