You compress it with various quality measures. After rotation, you use quality 100, so it will be a larger file than the previous one, with quality 55.
When you compress an image, it doesn't matter what the current file size / quality is. This does not have a real impact on the result. Quality compression of 55 and then quality of 100 does not result in the file being the same size as simple compression of quality 55. This results in a file with a compression size of 100, because this is the last thing to deal with it.
For your specific code, I'm not sure I see that the reason is because it compresses it twice. Compression (file size) is not what caused OOM problems during rotation, but image sizes were the most likely culprits. Reducing the image before rotation should fix this, there is no need to save a temporary file.
All you have to do is run reduceImage() and then execute it with fixRotation() . Correct your rotation method so that it accepts a Bitmap instead of a path, so you don't need to save the file between them. Finally, save / compress it with any quality you want.
If you need a temporary file for any reason, use PNG for the first compression. Thus, it is lossless, so when you recompress the final image, you will not use JPG (lose) twice at low quality.
Geobits
source share