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 focused. 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: https://svn.apache.org/repos/asf/incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/WriteExifMetadataExample.java ... outputSet = exif.getOutputSet(); TiffOutputDirectory thumbnailDirectory = outputSet.getExifThumbnailDirectory(); if(null != thumbnailDirectory) outputSet.removeDirectory(thumbnailDirectory); else // 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 TiffOutputSet.java. https://svn.apache.org/repos/asf/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputSet.java ... // new code public TiffOutputDirectory getExifThumbnailDirectory() { // I can't recall if the proper value here is DIRECTORY_TYPE_THUMBNAIL // or DIRECTORY_TYPE_SUB. // // see: https://svn.apache.org/repos/asf/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/TiffDirectoryConstants.java return findDirectory(DIRECTORY_TYPE_THUMBNAIL); } public void removeDirectory(TiffOutputDirectory directory) throws ImageWriteException { if(!directories.contains(directory)) throw new ImageWriteException( "Output set does not include that directory."); directories.remove(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 https://issues.apache.org/jira/browse/SANSELAN b) attaching your code to the ticket. Thanks, Charles On Tue, Feb 17, 2009 at 5:41 AM, Marko Mrkus <[email protected]> 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 > >
