Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.88k stars 2.16k forks source link

Same Input & Output With Different Settings #743

Open myalcinkuru opened 3 years ago

myalcinkuru commented 3 years ago

Do you want to request a feature or report a bug? It's a bug not a feature :)

What is the current behavior?

Result images are appears 90 degree rotated in imageview.

What is the expected behavior?

It should fix the orientation issue of Android as it fixes when the image is cropped.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Please attach any image files, URL and stack trace that can be used to reproduce the bug.

Which versions of uCrop, and which Android API versions are affected by this issue? Did this work in previous versions of uCrop?

uCrop Version = 2.2.4 (same 2.2.5) Test Android Api Version = 26

I think, it wasn't working in previous versions.

As i observed that uCrop won't make any changes if given file same as provided options. Below snippet proves that

` boolean shouldCrop = shouldCrop(mCroppedImageWidth, mCroppedImageHeight); if (shouldCrop) { ExifInterface originalExif = new ExifInterface(mImageInputPath); saveImage(Bitmap.createBitmap(mViewBitmap, cropOffsetX, cropOffsetY, mCroppedImageWidth, mCroppedImageHeight)); if (mCompressFormat.equals(Bitmap.CompressFormat.JPEG)) { ImageHeaderParser.copyExif(originalExif, mCroppedImageWidth, mCroppedImageHeight, mImageOutputPath); } return true; } else { FileUtils.copyFile(mImageInputPath, mImageOutputPath); return false; }

private boolean shouldCrop(int width, int height) { int pixelError = 1; pixelError += Math.round(Math.max(width, height) / 1000f); return (mMaxResultImageSizeX > 0 && mMaxResultImageSizeY > 0) || Math.abs(mCropRect.left - mCurrentImageRect.left) > pixelError || Math.abs(mCropRect.top - mCurrentImageRect.top) > pixelError || Math.abs(mCropRect.bottom - mCurrentImageRect.bottom) > pixelError || Math.abs(mCropRect.right - mCurrentImageRect.right) > pixelError || mCurrentAngle != 0; } ` This code taken from uCrop's BitmapCropTask class.

1- If shouldCrop return true, it just copies the file. So what if orientation is wrong ? 2- shouldCrop method doesn't return true even i set setMaxBitmapSize. That means my image size same as given if no cropping happens.