From fb3ba41b5b3854e2329794824d8d15c0fc1a1509 Mon Sep 17 00:00:00 2001 From: Jesse Chen Date: Thu, 31 Dec 2020 10:54:31 +0800 Subject: [PATCH] improvement: [MYX-1435] add an option to dislable rotation because it might cause performance issue --- src/camera.android.ts | 19 +++++++++++++------ src/index.d.ts | 5 +++++ src/package.json | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/camera.android.ts b/src/camera.android.ts index eff6ac4..573a2ea 100644 --- a/src/camera.android.ts +++ b/src/camera.android.ts @@ -115,12 +115,19 @@ export let takePicture = function (options?): Promise { let orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL); - if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_90) { - rotateBitmap(picturePath, 90); - } else if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_180) { - rotateBitmap(picturePath, 180); - } else if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_270) { - rotateBitmap(picturePath, 270); + if (!options.disableRotation) { + console.log('Rotating photo'); + + if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_90) { + console.log('Rotation: 90deg') + rotateBitmap(picturePath, 90); + } else if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_180) { + console.log('Rotation: 180deg') + rotateBitmap(picturePath, 180); + } else if (orientation === android.media.ExifInterface.ORIENTATION_ROTATE_270) { + console.log('Rotation: 270deg') + rotateBitmap(picturePath, 270); + } } if (shouldKeepAspectRatio) { diff --git a/src/index.d.ts b/src/index.d.ts index e465d5b..dd261a8 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -55,4 +55,9 @@ export interface CameraOptions { * The current implementation doesn't work on all Android devices, in which case it falls back to the default behavior. */ cameraFacing?: "front" | "rear"; + + /** + * Disable rotation after picture is taken (Android only for now) + */ + disableRotation?: boolean; } diff --git a/src/package.json b/src/package.json index 8d87d1e..ead55a3 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-camera", - "version": "4.5.0", + "version": "4.5.1", "description": "Provides API for using device camera", "repository": { "type": "git",