You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Charles Matthew Chen (JIRA)" <ji...@apache.org> on 2010/09/09 21:36:37 UTC

[jira] Resolved: (SANSELAN-38) JpegImageMetadata getEXIFThumbnail only works on Jpeg thumbnails stored as Tiff images.

     [ https://issues.apache.org/jira/browse/SANSELAN-38?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Charles Matthew Chen resolved SANSELAN-38.
------------------------------------------

    Resolution: Fixed

Commited patch from James EJ.
Added image from James EJ to test suite.

http://svn.apache.org/viewvc?view=revision&revision=995556


> 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
>         Attachments: img_F028c_small.jpg, jamesEJ_jpeg_patch.txt
>
>   Original Estimate: 0.33h
>  Remaining Estimate: 0.33h
>
> 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.