Reputation: 13
I have a base64 string that it contains an image which scanned by 300DPI and it size is around 500kb . I need to reduce file size to 300kb (+/- %20) without changing DPI in java. Resolution MUST be 300 DPI. I can't change it.
Hovewer, I don't care about dimensions (pixels). I could not figure out how can I do it. I hope, you can help me ?
Thanks:)
Upvotes: 0
Views: 124
Reputation: 3222
Since the size of the photographed object does not change (inches), and the resolution you mandate to be fixed at 300DPI (Dots/pixels per inch), the number of pixels in the image also cannot change.
The only thing you can do in order to reduce the file size is to compress it. Depending on the image contents, you can, for example, use JPEG compression and set its quality level to a setting that will yield a 300Kb output. Other compression methods may be more applicable, depending on the contents on the image. For example CCITT G4 compression for scanned black & white text.
Regarding how to compress, Google is your friend: https://www.google.com/search?q=compress+image+jpeg+java
Upvotes: 1