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