Compressing large images fails
On Android we first reduce the images size to a maximum of 1000px using a loop that downsamples to 1/4th of the images size in the previous iteration (by halving both width and height) and only then start compressing in yet another loop that reduces JPEG quality in every iteration.
I forgot to implement the first part and only do the second loop. Hence some images end up being not compressable to the desired size.