incubator-sanselan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Matthew Chen <>
Subject Re: Thumbnail removal with Sanselan
Date Wed, 18 Feb 2009 15:34:05 GMT
Hi Mark -

   Thanks for your interest in the project.

   This is an interesting idea for a new feature.  One feature I've
thought of adding for a long time would be a format-agnostic "strip"
function that would remove everything except the image data from an
image - ie. metadata, comments, thumbnails, etc.  This would certainly
do what you need, but I think you're looking for something more

   Removing just the Exif thubnails from Jpegs is actually fairly
simple.  Jpeg stores its EXIF metadata in a TIFF-structured segment.
TIFF data is arranged in a series of directories.  The thumbnail (if
present) is data is in a contained is a dedicated directory - removing
a thumbnail is thus a question of finding that directory and removing
it if present.

   It will require a fairly simple patch.  Here's how it will go:

1. Your code will be a variation on the jpeg metadata example code:

outputSet = exif.getOutputSet();
TiffOutputDirectory 	thumbnailDirectory = outputSet.getExifThumbnailDirectory();
if(null != thumbnailDirectory)
   // if the jpeg's exif metadata doesn't contain a thumbnail, should
we return and not bother updating the image?
// continue updating the image as in the example.

2. Second, we need to add a couple of methods to

// new  code
	public TiffOutputDirectory getExifThumbnailDirectory()
		// I can't recall if the proper value here is DIRECTORY_TYPE_THUMBNAIL
		// see:
		return findDirectory(DIRECTORY_TYPE_THUMBNAIL);
	public void removeDirectory(TiffOutputDirectory directory)
			throws ImageWriteException
			throw new ImageWriteException(
					"Output set does not include that directory.");
// end new code

   I haven't compiled or tested this code, so it may have some obvious
mistakes in it.  If you get this working, please consider contributing
a patch to the project by:
a) opening a JIRA ticket
b) attaching your code to the ticket.


On Tue, Feb 17, 2009 at 5:41 AM, Marko Mrkus <> wrote:
> Hi!
> As I see Sanselan provides a very easy way how to read and modify EXIF
> headers in JPEG files.
> Can you, please, tell me is it capable of removing thumbnail from JPEG and
> how to approach this problem?
> PS. keep up the good work :-)
> Thanks,
> Marko

View raw message