Examples of JpegSegmentReader


Examples of com.drew.imaging.jpeg.JpegSegmentReader

    @NotNull
    private static Metadata readMetadataFromJpegFile(String fileName) throws JpegProcessingException, IOException
    {
        Metadata metadata = new Metadata();
        byte[] data = new JpegSegmentReader(new File(fileName)).readSegment(JpegSegmentReader.SEGMENT_APP1);
        Assert.assertNotNull(data);
        new ExifReader().extract(new ByteArrayReader(data), metadata);
        return metadata;
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

        // Approach 3
        // As fast as approach 1 (this is what goes on inside the JpegMetadataReader's readMetadata() method), this code
        // is handy if you want to look into other Jpeg segments as well.
        try {
            JpegSegmentReader segmentReader = new JpegSegmentReader(file);
            byte[] exifSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APP1);
            byte[] iptcSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APPD);
            Metadata metadata = new Metadata();
            if (exifSegment != null)
                new ExifReader().extract(new ByteArrayReader(exifSegment), metadata);
            if (iptcSegment != null)
                new IptcReader().extract(new ByteArrayReader(iptcSegment), metadata);
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

{
    @Test
    public void testReadAdobeJpegMetadata1() throws Exception
    {
        final File metadataFile = new File("Tests/com/drew/metadata/adobe/adobeJpeg1.jpg");
        final JpegSegmentData jpegSegmentData = new JpegSegmentReader(metadataFile).getSegmentData();
        final byte[] bytes = jpegSegmentData.getSegment(JpegSegmentReader.SEGMENT_APPE);

        Assert.assertNotNull(bytes);

        final Metadata metadata = new Metadata();
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    @Before
    public void setUp() throws JpegProcessingException, IOException
    {
        // use a known testing image
        File jpegFile = new File("Tests/com/drew/metadata/jpeg/simple.jpg");
        final byte[] data = new JpegSegmentReader(jpegFile).readSegment(JpegSegmentReader.SEGMENT_SOF0);
        MetadataReader reader = new JpegReader();
        Metadata metadata = new Metadata();
        Assert.assertNotNull(data);
        reader.extract(new ByteArrayReader(data), metadata);
        Assert.assertTrue(metadata.containsDirectory(JpegDirectory.class));
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

     * @deprecated Not all files will be Jpegs!  Use a constructor that provides the exif segment in isolation.
     */
    public ExifReader(File jpegFile) throws JpegProcessingException
    {
        // TODO consider removing this constructor and requiring callers to pass a byte[] or other means to read the exif segment in isolation... not all files will be Jpegs!
        this(new JpegSegmentReader(jpegFile).readSegment(JpegSegmentReader.SEGMENT_APP1));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

     * @deprecated Not all files will be Jpegs!  Use a constructor that provides the exif segment in isolation.
     */
    public ExifReader(InputStream jpegInputStream) throws JpegProcessingException
    {
        // TODO consider removing this constructor and requiring callers to pass a byte[] or other means to read the exif segment in isolation... not all files will be Jpegs!
        this(new JpegSegmentReader(jpegInputStream).readSegment(JpegSegmentReader.SEGMENT_APP1));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    public void testIsJpegWithJpegFile() throws Exception
    {
        File jpeg = new File("Source/com/drew/metadata/exif/test/withExif.jpg");
        try {
            new JpegSegmentReader(jpeg);
        } catch (JpegProcessingException e) {
            fail("Error creating JpegSegmentReader");
        }
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    public void testIsJpegWithNonJpegFile() throws Exception
    {
        File nonJpeg = new File("Source/com/drew/metadata/test/AllTests.java");
        try {
            new JpegSegmentReader(nonJpeg);
            fail("shouldn't be able to construct JpegSegmentReader with non-jpeg file");
        } catch (JpegProcessingException e) {
            // expect exception
        }
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    }

    public void testReadApp1Segment() throws Exception
    {
        File jpeg = new File("Source/com/drew/metadata/exif/test/withExif.jpg");
        JpegSegmentReader segmentReader = new JpegSegmentReader(jpeg);
        byte[] exifData = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APP1);
        assertTrue("exif data too short", exifData.length > 4);
        assertEquals("Exif", new String(exifData, 0, 4));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    }

    public void testReadDQTSegment() throws Exception
    {
        File jpeg = new File("Source/com/drew/metadata/exif/test/withExif.jpg");
        JpegSegmentReader segmentReader = new JpegSegmentReader(jpeg);
        byte[] quantizationTableData = segmentReader.readSegment(JpegSegmentReader.SEGMENT_DQT);
        assertTrue("shouldn't have zero length quantizationTableData", quantizationTableData.length > 0);
        assertTrue("quantizationTableData shouldn't start with 'Exif'", !"Exif".equals(new String(quantizationTableData, 0, 4)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.