Examples of JpegSegmentReader


Examples of com.drew.imaging.jpeg.JpegSegmentReader

            else if (subItem.endsWith(".jpg") || subItem.endsWith(".jpeg"))
            {
                // process this item
                try
                {
                    JpegSegmentReader segmentReader = new JpegSegmentReader(file);
                    try
                    {
                        JpegMetadataReader.extractMetadataFromJpegSegmentReader(segmentReader);
                    }
                    catch (Throwable t)
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    public void testIsJpegWithJpegFile() throws Exception
    {
        File jpeg = new File("src/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("src/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("src/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("src/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

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    public void testReadJpegByteArray() throws Exception
    {
        File jpeg = new File("src/com/drew/metadata/exif/test/withExif.jpg");
        byte[] fileContents = new byte[(int)jpeg.length()];
        new FileInputStream(jpeg).read(fileContents);
        new JpegSegmentReader(fileContents).readSegment(JpegSegmentReader.SEGMENT_APP1);
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    public void testCreateWithInputStream() throws Exception
    {
        File jpeg = new File("src/com/drew/metadata/exif/test/withExif.jpg");
        InputStream in = new FileInputStream(jpeg);
        JpegSegmentReader reader = null;
        try {
            reader = new JpegSegmentReader(in);
        } catch (JpegProcessingException e) {
            fail("Error constructing JpegSegmentReader using InputStream");
        }
        // this will never happen, as fail() is guaranteed to throw an AssertionException
        if (reader==null)
            return;
        byte[] exifData = reader.readSegment(JpegSegmentReader.SEGMENT_APP1);
        assertEquals("Exif", new String(exifData, 0, 4));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    }

    public void testReadSecondSegmentInstanace() throws Exception
    {
        File jpeg = new File("src/com/drew/imaging/jpeg/test/withExifAndIptc.jpg");
        JpegSegmentReader reader = new JpegSegmentReader(jpeg);
        byte[] exifData0 = reader.readSegment(JpegSegmentReader.SEGMENT_APP1, 0);
        byte[] exifData1 = reader.readSegment(JpegSegmentReader.SEGMENT_APP1, 1);
        assertEquals("Exif", new String(exifData0, 0, 4));
        assertEquals("http", new String(exifData1, 0, 4));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    }

    public void testReadNonExistantSegmentInstance() throws Exception
    {
        File jpeg = new File("src/com/drew/imaging/jpeg/test/withExifAndIptc.jpg");
        JpegSegmentReader reader = new JpegSegmentReader(jpeg);
        assertNull("third exif segment shouldn't exist", reader.readSegment(JpegSegmentReader.SEGMENT_APP1, 3));
    }
View Full Code Here

Examples of com.drew.imaging.jpeg.JpegSegmentReader

    }

    public void testGetSegmentCount() throws Exception
    {
        File jpeg = new File("src/com/drew/imaging/jpeg/test/withExifAndIptc.jpg");
        JpegSegmentReader reader = new JpegSegmentReader(jpeg);
        assertEquals(2, reader.getSegmentCount(JpegSegmentReader.SEGMENT_APP1));
        assertEquals(1, reader.getSegmentCount(JpegSegmentReader.SEGMENT_APP2));
        assertEquals(0, reader.getSegmentCount(JpegSegmentReader.SEGMENT_APP3));
    }
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.