Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

targetWidth and targetHeight bigger than original picture #238

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/android/CameraLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,8 @@ private Bitmap getScaledAndRotatedBitmap(String imageUrl) throws IOException {
* @return
*/
public int[] calculateAspectRatio(int origWidth, int origHeight) {
int newWidth = this.targetWidth;
int newHeight = this.targetHeight;
int newWidth = Math.min(this.targetWidth, origWidth);
int newHeight = Math.min(this.targetHeight, origHeight);

// If no new width or height were specified return the original bitmap
if (newWidth <= 0 && newHeight <= 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/ios/UIImage+CropScaleOrientation.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize
CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat targetWidth = targetSize.width;
CGFloat targetHeight = targetSize.height;
CGFloat targetWidth = MIN(targetSize.width, width);
CGFloat targetHeight = MIN(targetSize.height, height);
CGFloat scaleFactor = 0.0;
CGFloat scaledWidth = targetWidth;
CGFloat scaledHeight = targetHeight;
Expand Down Expand Up @@ -136,8 +136,8 @@ - (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize
CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat targetWidth = targetSize.width;
CGFloat targetHeight = targetSize.height;
CGFloat targetWidth = MIN(targetSize.width, width);
CGFloat targetHeight = MIN(targetSize.height, height);
CGFloat scaleFactor = 0.0;
CGSize scaledSize = targetSize;

Expand Down