8

Is there anyway to remove an exif thumbnail from an image?

I'm cropping images in my app and copying all exif data lossless with the sanselan library. Afterwards, I update width/height/rotation accordingly.

I could not find any way to update the exif thumbnail or to remove it, any ideas how to do that?

Darush
  • 11,403
  • 9
  • 62
  • 60
prom85
  • 16,896
  • 17
  • 122
  • 242
  • 2
    The full `ExifInterface` code from the AOSP, such as [this set of code in the Camera2 app](https://android.googlesource.com/platform/packages/apps/Camera2/+/master/src/com/android/camera/exif/ExifInterface.java), has methods to work with EXIF thumbnails. – CommonsWare Jun 26 '16 at 16:09
  • I'll check that out. On my first look, following library seems to use the same code: https://github.com/sephiroth74/Android-Exif-Extended... Won't work with streams though... – prom85 Jun 26 '16 at 16:18
  • PS: I think looking into the code I can adjust that to sanselan classes... – prom85 Jun 26 '16 at 16:20

1 Answers1

0

I have similar kind of problem of exif data

private void removeThumbnails(ContentResolver contentResolver, long photoId) {
        try {
            Cursor thumbnails = contentResolver.query(
                    MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, null, MediaStore.Images.Thumbnails.IMAGE_ID
                            + "=?", new String[]{String.valueOf(photoId)}, null);
            if (thumbnails != null) {
                for (thumbnails.moveToFirst(); !thumbnails.isAfterLast() && !thumbnails.isBeforeFirst(); thumbnails.moveToNext()) {

                    long thumbnailId = thumbnails.getLong(thumbnails.getColumnIndex(MediaStore.Images.Thumbnails._ID));
                    String path = thumbnails.getString(thumbnails.getColumnIndex(MediaStore.Images.Thumbnails.DATA));
                    File file = new File(path);
                    if (file.delete()) {
                        contentResolver.delete(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, MediaStore.Images.Thumbnails._ID + "=?",
                                new String[]{String.valueOf(thumbnailId)});
                    }
                }
                thumbnails.close();
            }
        } catch (Exception e) {
        }
    }

So I have removed the thumbnail of it first then done the operation on the image

So u can try removing the thumbnail and try to crop it after

Amjad Khan
  • 1,309
  • 15
  • 32