Batch Resize to 150dpi

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
dakheli54
Posts: 2
Joined: 2016-08-28T08:12:28-07:00
Authentication code: 1151

Batch Resize to 150dpi

Post by dakheli54 »

I have many image files, each in different dpi,
I need to convert (resize) all of them to 150 dpi,
I mean :
if an image size is 1000x1000 @ 300 dpi, It must be resized to 500x500
if an image size is 1000x1000 @ 600 dpi, It must be resized to 250x250
So, Both resize and density change are needed,
How do I do this using Convert utility
changing density does not resize.
Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch Resize to 150dpi

Post by snibgo »

Perhaps "-resample" does what you want. See http://www.imagemagick.org/script/comma ... p#resample
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Batch Resize to 150dpi

Post by GeeMack »

dakheli54 wrote:I have many image files, each in different dpi,
I need to convert (resize) all of them to 150 dpi,
I mean :
if an image size is 1000x1000 @ 300 dpi, It must be resized to 500x500
if an image size is 1000x1000 @ 600 dpi, It must be resized to 250x250
This can be done very easily with ImageMagick 7. What IM version are you using and what operating system are you working on?

Edited: The simple answer is to use "-resample" as mentioned above by snibgo.
dakheli54
Posts: 2
Joined: 2016-08-28T08:12:28-07:00
Authentication code: 1151

Re: Batch Resize to 150dpi

Post by dakheli54 »

snibgo & GeeMack,Thanks for prompt response,
A newbie in this, I use IM7 Convert utility in Win10.
from the description of -resample, a final resolution must be defined , don't know how to do it in batch operation.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch Resize to 150dpi

Post by snibgo »

To resample all the jpg files in your currect directory:

Code: Select all

magick mogrify -resample 150 *.jpg
But do a backup first in case this doesn't do what you want.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Batch Resize to 150dpi

Post by GeeMack »

dakheli54 wrote:from the description of -resample, a final resolution must be defined , don't know how to do it in batch operation.
If the number and size of images in your current working directory fit in your memory it can be as simple as this...

Code: Select all

magick mogrify -resample 150 *.jpg
That will change the density of all the JPGs in the current directory to 150dpi and resize them to match the new resolution. It will overwrite the existing images, so you may want to set aside backup copies. Also if you're processing JPGs there will be some loss due to compression. You can apply a setting something like "-quality 100" to save them at the best quality, but it's not lossless.
Post Reply