Compressor icon indicating copy to clipboard operation
Compressor copied to clipboard

Definieg maximum size does not work

Open Bluestart83 opened this issue 7 years ago • 4 comments

Hi, setMaxWidth and setMaxSize is only used for image sampling, I don't have the requested image pixel numbers in output. (I've checked in code also).

Im using 2.1.0 version.

Bluestart83 avatar Oct 26 '17 13:10 Bluestart83

I just was checking image sizes and I see the same problem. I have set max height and width but I see pictures with much longer sizes than set

Mistic92 avatar Oct 26 '17 19:10 Mistic92

private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth) {
        while ((height / inSampleSize) >= reqHeight || (width / inSampleSize) >= reqWidth) {
            inSampleSize *= 2;
        }
    }
    return inSampleSize;
}

this is my solution

songsongtao avatar Dec 28 '17 07:12 songsongtao

I come to write the same @songsongtao , there are any PR with this code that we can vote up?

Aracem avatar Jan 17 '18 11:01 Aracem

Same issue, I have setMaxWidth(3072) and setMaxHeight(3072), but the result file size is 2304 x 4096.

phoeson avatar Sep 26 '18 04:09 phoeson