Compressor icon indicating copy to clipboard operation
Compressor copied to clipboard

custom width nd height not working

Open shanvpz opened this issue 7 years ago • 5 comments

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

shanvpz avatar Jan 06 '19 05:01 shanvpz

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

lewkka avatar Jan 13 '19 20:01 lewkka

same

zihadrizkyef avatar Feb 12 '19 03:02 zihadrizkyef

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.

mtrezza avatar Apr 30 '19 16:04 mtrezza

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

Shouheng88 avatar Jun 05 '19 09:06 Shouheng88

这个问题还没解决吗?

13242445359 avatar Oct 31 '19 02:10 13242445359