Skip to content

Commit

Permalink
Fix scaling in camera plugin when setting only height
Browse files Browse the repository at this point in the history
This fixes a bug where giving a prescribed `height` when scaling results in an
image with inverted aspect ratio (i.e. trying to scale a portrait image would
yield a landscape result and vice versa).
  • Loading branch information
zyniq82 committed Nov 1, 2019
1 parent 4b8fc3e commit 6968b86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Bitmap resize(Bitmap bitmap, final int width, final int height) {
} else if (width > 0) {
return Bitmap.createScaledBitmap(bitmap, width, (int) (width * 1/aspect), false);
} else if (height > 0) {
return Bitmap.createScaledBitmap(bitmap, (int)(height * 1/aspect), height, false);
return Bitmap.createScaledBitmap(bitmap, (int) (height * aspect), height, false);
}

return bitmap;
Expand Down
2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/Plugins/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public class CAPCameraPlugin : CAPPlugin, UIImagePickerControllerDelegate, UINav
if settings.width > 0 {
size = CGSize.init(width: Int(settings.width), height: Int(settings.width * (1/aspect)))
} else if settings.height > 0 {
size = CGSize.init(width: Int(settings.height * (1/aspect)), height: Int(settings.height))
size = CGSize.init(width: Int(settings.height * aspect), height: Int(settings.height))
}
}

Expand Down

0 comments on commit 6968b86

Please sign in to comment.