1


I need to resize image based on memory.
What I am getting is following option in "convert" command.

-resize 800x600
-resize 25%

Is there any command like -

-resize 10KB

Thanks

user811602
  • 1,314
  • 2
  • 17
  • 47

1 Answers1

1

Use this:

convert input.jpg -define jpeg:extent=300kb ... output.jpg

If you want a way to do something similar with Python, I wrote an answer that works pretty well here. It does a binary search for a JPEG quality that satisfies a maximum size requirement.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Hi Mark, It is not giving desired output :
    convert vik.jpg -define jpeg:extent=10kb out.jpg
    -rw-rw-r-- 1 user user 22920 Oct 3 00:17 vik.jpg
    -rw-rw-r-- 1 user user 25144 Oct 29 19:40 out.jpg
    – user811602 Oct 29 '14 at 14:12
  • It may not be possible for such a small size. Try adding `-strip` too. And try larger sizes too. – Mark Setchell Oct 29 '14 at 14:15