1

Scenario: I have an android app which captures images and sends over to a server. Till now I had been setting 50% quality. But with high end phones with better sensors and resolutions even with that quality images end up with a size greater than a MB.

If i decrease quality lower end cameras will suffer and I can't afford to push 1 MB image.

So, I am looking for a way to compress image with a size limit, say 300 KB.

How do I accomplish this? or Is this even a right approach to the problem that I am having?

  • You'd better ask it on SO. Your question should be like "what JPEG library outputs files of arbitrary size?" or "what is the way of saving images of fixed size withing Android API?" – Euri Pinhollow Dec 24 '16 at 8:56
  • 3
    This belongs to StackOverflow. – Euri Pinhollow Dec 24 '16 at 8:58
  • 1
    Save the JPEG as you already do and if the file is too big, simply resize the image and retry. Repeat as needed. – szulat Dec 24 '16 at 9:01
  • @EuriPinhollow Unless it is a programming problem, I would suggest Super User. – Mick Dec 24 '16 at 9:02
  • 1
1

Scenario: I have an android app which captures images and sends over to a server. Till now I had been setting 50% quality. But with high end phones with better sensors and resolutions even with that quality images end up with a size greater than a MB.

If you apply compression of any kind with the constraint being the final file size then you will ALWAYS suffer data loss and hence quality loss. The simple act of choosing to compress the files in this way defines the final level of detail possible, so your choice in compressing in this way guarantees that higher quality images will likely be compromised more.

However, I would personally not worry about the alleged quality loss for higher MP phones. Simply having more MP does not generally produce useful detail. The optics are limited by other factors and the high MP counts are to a large extent just a marketing gimmick.

If i decrease quality lower end cameras will suffer and I can't afford to push 1 MB image.

The obvious solution is to not send it that way, but to save to a card and transfer the card's data using a card reader later, perhaps sending the final files to the mystery server over e.g. you home broadband connection which may have better speeds and costs.

So, I am looking for a way to compress image with a size limit, say 300 KB.

I don't use Android so I've no app to tell you. On a PC I'd use something like ImageMagick ( e.g. this question https://stackoverflow.com/questions/6917219/imagemagick-scale-jpeg-image-with-a-maximum-file-size ).

If you're a developer of an Android app then you need to ask how to save files to specific size constraints on the appropriate StackExchange forum.

In your case if possible save the files to your SD card and then read them to a laptop or desktop computer and batch convert them with ImageMagick. Sounds long winded but if you do it regularly then it will become quite trivial with practice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.