Compare commits
1 Commits
master
...
exif-same-
| Author | SHA1 | Date |
|---|---|---|
|
|
bd544eb7d2 |
|
|
@ -34,6 +34,7 @@ import android.provider.MediaStore;
|
|||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
|
@ -420,10 +421,8 @@ public class CropImageActivity extends MonitoredActivity {
|
|||
|
||||
if (!IN_MEMORY_CROP) {
|
||||
// In-memory crop negates the rotation
|
||||
CropUtil.copyExifRotation(
|
||||
CropUtil.getFromMediaUri(this, getContentResolver(), sourceUri),
|
||||
CropUtil.getFromMediaUri(this, getContentResolver(), saveUri)
|
||||
);
|
||||
File saveFile = CropUtil.getFromMediaUri(this, getContentResolver(), saveUri);
|
||||
CropUtil.saveExifRotation(saveFile, exifRotation);
|
||||
}
|
||||
|
||||
setResultUri(saveUri);
|
||||
|
|
|
|||
|
|
@ -68,21 +68,20 @@ class CropUtil {
|
|||
return ExifInterface.ORIENTATION_UNDEFINED;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e("Error getting Exif data", e);
|
||||
Log.e("Error reading Exif rotation data", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean copyExifRotation(File sourceFile, File destFile) {
|
||||
if (sourceFile == null || destFile == null) return false;
|
||||
public static boolean saveExifRotation(File file, int exifRotation) {
|
||||
if (file == null) return false;
|
||||
try {
|
||||
ExifInterface exifSource = new ExifInterface(sourceFile.getAbsolutePath());
|
||||
ExifInterface exifDest = new ExifInterface(destFile.getAbsolutePath());
|
||||
exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, exifSource.getAttribute(ExifInterface.TAG_ORIENTATION));
|
||||
ExifInterface exifDest = new ExifInterface(file.getAbsolutePath());
|
||||
exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(exifRotation));
|
||||
exifDest.saveAttributes();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Log.e("Error copying Exif data", e);
|
||||
Log.e("Error saving Exif rotation data", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue