Resize images to a certain size?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
traoiu
Posts: 3
Joined: 2019-09-10T18:49:37-07:00
Authentication code: 1152

Resize images to a certain size?

Post by traoiu »

Will ImageMagick be able to resize large amount of images to a certain size ( Eg; 40 KB) using optimization compression while keeping the image height and width,however if it's unable to do so , certain dpi resizing will happen which then allows it to reach target size?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resize images to a certain size?

Post by snibgo »

You would need a script for that.
snibgo's IM pages: im.snibgo.com
traoiu
Posts: 3
Joined: 2019-09-10T18:49:37-07:00
Authentication code: 1152

Re: Resize images to a certain size?

Post by traoiu »

snibgo wrote: 2019-09-10T19:19:29-07:00 You would need a script for that.
If I had a script ,I would be able to do that i'm assuming?


Thanks for the reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize images to a certain size?

Post by fmw42 »

That is possible with JPG output. See -define jpeg:extent={size} at https://imagemagick.org/Usage/formats/#jpg_write

DPI only affects print size, not raster image size unless you change width and height accordingly.
traoiu
Posts: 3
Joined: 2019-09-10T18:49:37-07:00
Authentication code: 1152

Re: Resize images to a certain size?

Post by traoiu »

Just clarifying, so does the width/height change if I were to use the cmd -define jpeg:extent={size} or something else happens?
Sorry if im being confusing and thank you for replying.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize images to a certain size?

Post by fmw42 »

The width and height do not change. That define will tell imagemagick the size you want and it will iterate changing the quality value (compression) until it reaches that image size. But it is limited to JPG output only.
Post Reply