user811602
user811602

Reputation: 1354

Resize image based on memory size


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

Upvotes: 1

Views: 379

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207345

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.

Upvotes: 1

Related Questions