1

How to resize jpg image to fit certain bytesize?

I am implementing a client app which should send images not exeding 200KB. However some images sometimes exceed 200KB(JPG).

I tried ImageMagick, "extent" command, however it seems that it deals with compression rather than image dimensions, whereas I need to preserve compression rate(Edit 1: quality) and resize only dimensions.

I am using java's ImageIO through Clojure and there also seems to be no exact solution.

Mr Davron
  • 97
  • 1
  • 7
  • 1
    check out this question if it may help you https://stackoverflow.com/questions/2305670/how-to-resize-the-original-image-into-a-common-size-of-image-in-java – bakero98 Jun 25 '19 at 11:58
  • 2
    "I need to preserve compression rate" -- if you resize the image, it will be re-compressed. – vlumi Jun 25 '19 at 12:06
  • @bakero98 I can't find the solution in the link provided. – Mr Davron Jun 25 '19 at 12:07
  • If you resize a jpg that has a specific quality with ImageMagick and specify no different -quality value, the output should use the same quality value to recompress. Use imagemagick identify to check the quality value before and after resizing. – fmw42 Jun 25 '19 at 16:29
  • 1
    Another Java only thread that might be useful: https://stackoverflow.com/questions/7951290/re-sizing-an-image-without-losing-quality – Denis Fuenzalida Jun 26 '19 at 05:20

0 Answers0