zetbaitsu / Compressor

An android image compression library.
7.08k stars 963 forks source link

custom width nd height not working #121

Open shanvpz opened 5 years ago

shanvpz commented 5 years ago

when i tried custom compress, the height and widths are not changing, file size ok.

lewkka commented 5 years ago

Yeah, looks like they just ignored. For my case width and height changed, but not in the numbers I set for Compressor.

zihadrizkyef commented 5 years ago

same

mtrezza commented 5 years ago

The parameters for setMaxWidth and setMaxHeight work differently than their names may suggests.

They define the minimum required width and height of the compressed image. Downsampling happens by the power of 2, so the image size will be divided by 2 until the minimum height or weight is reached. But because these are the minimum values for width and height, the image will not be smaller than these values but always larger. Depending on how close the downsampling comes to these values, the final image width and height can be more or less above these values.

Funny enough, the variable names that are set with setMaxWidth and setMaxHeight are reqWidth and reqHeight, so only the method names are confusing.

This library currently does not provide a way to set the max height and width where the final image size would not exceed these values.

Shouheng88 commented 5 years ago

you can try my library: https://github.com/Shouheng88/Compressor

13242445359 commented 5 years ago

这个问题还没解决吗?