How to Change the Resolution of an Image

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Change the Resolution of an Image

Post by fmw42 »

use -crop +repage. you can add that multiple time in a command line. Be sure to add +repage or you will not get the output as you want as it leaves the virtual canvas unchanged.

see -crop and +repage

http://www.imagemagick.org/script/comma ... s.php#crop
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/Usage/crop/#crop

convert input -crop ... +repage -crop ... +repage output
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to Change the Resolution of an Image

Post by anthony »

If you know the amount to remove from each side then 'chop' with gravity settings may be better. no need for +repage with chop.
http://www.imagemagick.org/Usage/crop/#chop

Actually you can do the four sides (with different amounts removed) with two -chops.

Code: Select all

   convert  ...   -gravity NorthWest -chop 10x20 \
                      -gravity SouthEast -chop 30x40 \
                 +gravity  ...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Change the Resolution of an Image

Post by fmw42 »

Not sure if he wants one image cropped twice to one output or one image cropped twice to two separate outputs!
psuphish05

Re: How to Change the Resolution of an Image

Post by psuphish05 »

Guys, thanks again for all your help. I was able to do multiple crops on the image by specifying the crop command multiple times:

convert -density 300 BC122.eps -crop 100%x100%-XXX+0^ -crop 100%x100%+0+XXX^ -density 72 -quality 35 -resize 165x165 BC122.jpg

The XXX is just our crop value in pixels. The command above will crop the top and right sides of the image. I'm not too worried if this isn't fast or the cleanest way to do it - even though, I'd be interested to see how else it could be accomplished for my own good.

Thanks again, you guys have been a great help!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Change the Resolution of an Image

Post by fmw42 »

see Anthony's reference to -chop, it will be shorter and more efficient.
Post Reply