Java/AndroidでExifを削除する時にsanselanという便利なライブラリを使わせて頂きました。
このライブラリを使った理由は、metadata-extractorは読み取り専用なのでExif情報の削除や追加・修正が出来ないこと、ExifInterfaceは挙動が不安定なため使えなかったからです。
使い方
/* import省略 */
public static void Main(String[] args) {
String path1 = "c:\image\img0001.jpg"; // ファイルパス
String path2 = path.toLowerCase().replace(".jpg", "_clr_exif.jpg");
// Exif情報の削除
removeExifTag(new File(path1), new File(path2));
}
public static void removeExifTag(final File srcJpegFile, final File dstJpegFile) {
OutputStream os = null;
try {
os = new FileOutputStream(dstJpegFile);
os = new BufferedOutputStream(os);
// Exif削除メソッド
new ExifRewriter().removeExifMetadata(srcJpegFile, os);
os.close();
os = null;
System.out.println("SUCCESS");
} catch (FileNotFoundException e) {
System.out.println("ERROR");
e.printStackTrace();
} catch (ImageWriteException e) {
System.out.println("ERROR1");
e.printStackTrace();
} catch (IOException e) {
System.out.println("ERROR2");
e.printStackTrace();
} catch (ImageReadException e) {
e.printStackTrace();
} finally {
if (os != null) {
try {
os.close();
} catch (final IOException e) {
}
}
}
}