commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James E-J (JIRA)" <j...@apache.org>
Subject [jira] Created: (SANSELAN-38) JpegImageMetadata getEXIFThumbnail only works on Jpeg thumbnails stored as Tiff images.
Date Fri, 12 Mar 2010 00:52:27 GMT
JpegImageMetadata getEXIFThumbnail only works on Jpeg thumbnails stored as Tiff images.
---------------------------------------------------------------------------------------

                 Key: SANSELAN-38
                 URL: https://issues.apache.org/jira/browse/SANSELAN-38
             Project: Commons Sanselan
          Issue Type: Bug
         Environment: Windows Vista, Java 6 SE, incubator 0.97 and 0.98 SNAPSHOT
            Reporter: James E-J


JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
BufferedImage image = jpegMetadata.getEXIFThumbnail();

Above code seaches tiff directory structure but only searches for dir.getTiffImage() and only
checks if tiffImageData is null. Jpeg files which have Jpeg thumbs stored as JpegImageData
do not work.

I was able to fix this with following code:
import org.apache.sanselan.formats.tiff.JpegImageData;
import javax.imageio.ImageIO;
import java.io.ByteArrayInputStream;


	public BufferedImage getEXIFThumbnail() throws ImageReadException,
			IOException {
		ArrayList dirs = exif.getDirectories();
		for (int i = 0; i < dirs.size(); i++) {
			TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
					.get(i);
			// Debug.debug("dir", dir);
			BufferedImage image = dir.getThumbnail();
			if (null != image)
				return image;
                        JpegImageData jpegImageData = dir.getJpegImageData();
                        if(jpegImageData!=null){
                            ByteArrayInputStream input = new ByteArrayInputStream(jpegImageData.data);
                            image = ImageIO.read(input);
                            if (image!=null)
                                return image;
                        }
		}

		return null;
	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message