Hello all,
I've been reading about -crop and image geometry for a few hoursas well as wrestling with the examples, but I can't get this right: I would like to get a fixed-sized crop around a point, even it it goes partially outside the image border. For instance I want a resulting Width and Height of 100, around point (30,60), so a crop that goes from (-20,10) to (80,110). I don't care what it fills the gap with. I've been wrestling with the +/- signs and ! in the geometry expression to no avail.
Centered crop
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Centered crop
try
convert image.png -crop 100x100-20+10\! -background lightblue -flatten image_crop_flat.png
see http://www.imagemagick.org/Usage/crop/#crop_viewport
change the background color to whatever you want
convert image.png -crop 100x100-20+10\! -background lightblue -flatten image_crop_flat.png
see http://www.imagemagick.org/Usage/crop/#crop_viewport
change the background color to whatever you want
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Centered crop
for cropping around a specific center point on alternative is to use a distort with a viewport into the distorted image. distort viewport
for example translate the center point to crop around to origin, then viewport around the origin.
substitute logo: for input image\
388,226 for the center point
show: for the output image
and adjust viewport for size.
for example translate the center point to crop around to origin, then viewport around the origin.
Code: Select all
convert logo: -set option:distort:viewport 101x101-50-50 \
-distort affine '388,226 0,0' +repage logo_nose.png
substitute logo: for input image\
388,226 for the center point
show: for the output image
and adjust viewport for size.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/