Simple-Gallery
Simple-Gallery copied to clipboard
Image resize needs substantial improvement
The app is awesome, but the resize feature probably uses nearest neighbor resampling algorithm. This leads to visible image quality degradation, especially on images with something like stripes or tiny checkerboards.
Take a look at the original and the cropped\resized image:
To avoid this, you'll need to use bilinear resampling either by setting last flag to True here:
val resized = Bitmap.createScaledBitmap(bitmap, resizeWidth, resizeHeight, false)
or, ideally, utilizing specialized library that can use separate algorithms for optimal resizing to larger and smaller sizes. Probably Glide could be useful?
Im using https://github.com/ArthurHub/Android-Image-Cropper for that, check if they have something similar reported.
I see no similar reports on the cropper, however looking at its code, the root cause seems to be exactly as I've outlined above :) https://github.com/ArthurHub/Android-Image-Cropper/blob/master/cropper/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java line 425, 433: if (options == CropImageView.RequestSizeOptions.RESIZE_EXACT) { resized = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, false); } else {
you might want to report it there, to see what does the creator have to say about it. It isnt really an active project anymore though.
I second that, "nearest" is really awful quality.
@tibbi, any plans to improve the resizing? Unfortunately, this is the major drawback of the program — the text on resized screenshots looks very low quality.
It seems the upstream project is unmaintained, there are no replies on the related issue. It seems there are forks, one is mentioned on the issue, though it don't know if it's trustworthy.
I cannot vouch for trustworthiness, but this fork is actively maintained/developed and has a guide on migrating to it from the old version: https://github.com/CanHub/Android-Image-Cropper The guide is on that page, a little lower down. I believe it would be beneficial to migrate to it, as this should take care of many existing and future bugs and issues. Investigating it further might be a good idea.