commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SANSELAN-38) JpegImageMetadata getEXIFThumbnail only works on Jpeg thumbnails stored as Tiff images.
Date Tue, 20 Dec 2011 10:53:30 GMT

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

Emmanuel Bourg updated SANSELAN-38:
-----------------------------------

      Description: 
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:
{code:java}
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;
	}
{code}

  was:
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;
	}

    Fix Version/s: 1.0
    
> 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
>              Labels: bufferedimage, getexifthumbnail, imageio, jpeg, jpegimagedata, thumbnail
>             Fix For: 1.0
>
>         Attachments: img_F028c_small.jpg, jamesEJ_jpeg_patch.txt
>
>   Original Estimate: 20m
>  Remaining Estimate: 20m
>
> 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:
> {code:java}
> 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;
> 	}
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message