Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Exif Orientation data is not copied if you use the same Uri for both Input and Output #59

Open
apinder opened this issue Dec 4, 2014 · 0 comments
Labels

Comments

@apinder
Copy link

apinder commented Dec 4, 2014

This was tested on a 2.3.3 device; easy work around is to simply make sure the output URI is different from the input URI but may be causing issues related to #46.

Relevant code is
(https://github.com/brandon515/android-crop/blob/aa6023d8cb276805ec883f3eecaec4c4949007a6/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java#L407):

       try {
            outputStream = getContentResolver().openOutputStream(saveUri);
            if (outputStream != null) {
                croppedImage.compress(Bitmap.CompressFormat.JPEG, 90, outputStream);
            }
        } catch (IOException e) {
            setResultException(e);
            Log.e("Cannot open file: " + saveUri, e);
        } finally {
            CropUtil.closeSilently(outputStream);
        }

        if (!IN_MEMORY_CROP) {
            // In-memory crop negates the rotation
            CropUtil.copyExifRotation(
                    CropUtil.getFromMediaUri(getContentResolver(), sourceUri),
                    CropUtil.getFromMediaUri(getContentResolver(), saveUri)
            );
        }
  1. Output Uri gets written to by the bitmap (which is also input)
  2. Exif orientations get copied from input to output
  3. Exif data is lost as the bitmap has already overwritten it leaving the image with no Exif data so it's not possible to orientate the image correctly.

I'd do the fix myself but really need an IDE for this fix and it doesn't appear to be easily importable into Eclipse (I ain't savvy with Gradle and Android Dev Tools)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants