[ 
https://issues.apache.org/jira/browse/CB-13683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16598792#comment-16598792
 ] 

ASF GitHub Bot commented on CB-13683:
-------------------------------------

mcelotti commented on a change in pull request #100: CB-13683: (android) 
cordova-plugin-media-capture rotates pictures with some devices
URL: 
https://github.com/apache/cordova-plugin-media-capture/pull/100#discussion_r214376952
 
 

 ##########
 File path: src/android/Capture.java
 ##########
 @@ -537,6 +554,51 @@ private Uri whichContentStore() {
         }
     }
 
+    @Nullable
+    private Bitmap rotateAccordingToExifOrientation(Uri uri) {
+        Context context = this.cordova.getContext();
+        int orientation;
+        Bitmap bitmap;
+        try {
+            InputStream inputStream = 
context.getContentResolver().openInputStream(uri);
+            if (inputStream == null)
+                throw new IOException("input stream from ContentResolver is 
null");
+            ExifInterface ei = new ExifInterface(inputStream);
+            orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, 
ExifInterface.ORIENTATION_UNDEFINED);
+            bitmap = 
MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri);
+        } catch (IOException e) {
+            LOG.e(LOG_TAG, "Failed reading bitmap", e);
+            return null;
+        }
+
+        Bitmap rotatedBitmap;
+        switch (orientation) {
+            case ExifInterface.ORIENTATION_ROTATE_90:
+                rotatedBitmap = rotateImage(bitmap, 90);
+                break;
+
+            case ExifInterface.ORIENTATION_ROTATE_180:
+                rotatedBitmap = rotateImage(bitmap, 180);
+                break;
+
+            case ExifInterface.ORIENTATION_ROTATE_270:
+                rotatedBitmap = rotateImage(bitmap, 270);
+                break;
+
+            case ExifInterface.ORIENTATION_NORMAL:
+            default:
+                rotatedBitmap = bitmap;
+        }
+        return rotatedBitmap;
+    }
+
+    private Uri fromBitmapToUri(Context context, Bitmap inImage) {
+        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+        inImage.compress(Bitmap.CompressFormat.JPEG, 85, bytes);
 
 Review comment:
   Ok, the compression is now 100 abed3674d13a5f380c5c1f779ae49752f0d5c9f1

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> cordova-plugin-media-capture: Rotates pictures in android devices 
> ------------------------------------------------------------------
>
>                 Key: CB-13683
>                 URL: https://issues.apache.org/jira/browse/CB-13683
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-media-capture
>         Environment: Plugin name: cordova-plugin-media-capture
> Version: 2.0.0
> Used in: Ionic project
> Device: Samsung Galaxy J3
>            Reporter: hsob
>            Priority: Critical
>
> When I take picture using device camera (cordova-plugin-media-capture), the 
> result is a rotated picture in all tested devices using android. But in iOS 
> devices these is not issue.
> How can I fixe this?
> Thanks



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to