Hi.
I have some images that I would like to risize to shortest side, then cop the logest side and then put a mask to it.
I have this code:
// resize
$cmd = "convert $image -resize 212x250^ -gravity center -extent 212x250 $new_name";
exec("$cmd");
//mask
$cmd = "composite $new_name $overlay $mask $new_name";
exec("$cmd");
I use PHP.
The first part does resize and crop, but as soon as I add the mask part, it crops the imge to 212x212 pixels.
My mask-image is 212x250 pixels.
Is there another way to do this, maybe in one line of code?
Resize, crop and then mask
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resize, crop and then mask
try using convert rather than composite. note the composite and convert commands require the two input images to be reversed relative to each other. I think you have them the wrong way for composite. But this should do it in one command
convert \( image -resize 212x250^ -gravity center -extent 212x250 \) overlay mask -composite result
for this you probably don't need the parens, so this should work
convert image -resize 212x250^ -gravity center -extent 212x250 overlay mask -composite result
presumably the overlay and mask images are also 212x250
convert \( image -resize 212x250^ -gravity center -extent 212x250 \) overlay mask -composite result
for this you probably don't need the parens, so this should work
convert image -resize 212x250^ -gravity center -extent 212x250 overlay mask -composite result
presumably the overlay and mask images are also 212x250
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Resize, crop and then mask
See also IM Examples,
Cut to Fit (Thumbnails)
http://www.imagemagick.org/Usage/thumbnails/#cut
Composite Masking
http://www.imagemagick.org/Usage/compose/#mask
Or more specifically Paint and Mask
http://www.imagemagick.org/Usage/thumbnails/#paint_mask
Their is also a "mask and paint" technique that seems to work better!
read that whole section for more ideas and techniques.
Cut to Fit (Thumbnails)
http://www.imagemagick.org/Usage/thumbnails/#cut
Composite Masking
http://www.imagemagick.org/Usage/compose/#mask
Or more specifically Paint and Mask
http://www.imagemagick.org/Usage/thumbnails/#paint_mask
Their is also a "mask and paint" technique that seems to work better!
read that whole section for more ideas and techniques.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/