Skip to content

Commit

Permalink
improvement: [MYX-1435] add an option to dislable rotation because it
Browse files Browse the repository at this point in the history
might cause performance issue
  • Loading branch information
jesse-xrex committed Dec 31, 2020
1 parent f9cf55f commit fb3ba41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/camera.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,19 @@ export let takePicture = function (options?): Promise<any> {
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) {
Expand Down
5 changes: 5 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit fb3ba41

Please sign in to comment.