source: josm/trunk/lib/metadata-extractor-2.3.1-nosun.diff@ 1776

Last change on this file since 1776 was 392, checked in by gebner, 17 years ago

Fix build for the IcedTea JDK.

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;  
    2525import com.drew.metadata.iptc.IptcReader;
    2626import com.drew.metadata.jpeg.JpegCommentReader;
    2727import com.drew.metadata.jpeg.JpegReader;
    28 import com.sun.image.codec.jpeg.JPEGDecodeParam;
    2928
    3029import java.io.File;
    3130import java.io.IOException;
    public class JpegMetadataReader  
    8988        return metadata;
    9089    }
    9190
    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 exists
    97          * because markers can theoretically appear multiple times in the file.
    98          */
    99         // TODO test this method
    100         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 segment
    106         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 segment
    114         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 
    12291    private JpegMetadataReader()
    12392    {
    12493    }
  • 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;  
    2121import com.drew.imaging.jpeg.JpegSegmentReader;
    2222import com.drew.metadata.exif.ExifReader;
    2323import 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;
    2724
    2825import java.awt.image.BufferedImage;
    2926import java.io.File;
    public class SampleUsage  
    8784        } catch (JpegProcessingException jpe) {
    8885            System.err.println("error 3a");
    8986        }
    90        
    91         // Approach 4
    92         // This approach is the slowest, because it decodes the Jpeg image.  Of
    93         // course you now have a decoded image to play with.  In some instances
    94         // 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 image
    99             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         }
    10787    }
    10888
    10989    private void printImageTags(int approachCount, Metadata metadata)
Note: See TracBrowser for help on using the repository browser.