问题
I am having image1.jpg with the size of 350x500 and another image2.png ( 350x150 ) with gradient effects like shadow. I need to apply the shadow to image1.jpg in its bottom. But geometry doesn't work for me.
convert -extent 600x700\! image1.jpg \( image2.png -geometry +0+500 \) -composite final.png
I hope the geometry will position an image at the point I have given, If I am right, geometry is not working for me.
回答1:
Not certain what you are trying to achieve, but is this close:
convert xc:red[350x500] -extent 600x700\! xc:blue[350x150] -geometry +80+300 -composite result.png
Maybe you have some left-over paging info in your PNG file, you can remove it by adding +repage
immediately after loading it:
convert ... ... image.png +repage ...
You can identify it like this:
回答2:
Perhaps what you want is to use combinations of -gravity and -geometry in ImageMagick. For example
convert -size 600x700 xc:white xc:red[350x500] -geometry +50+50 -composite xc:blue[350x150] -gravity south -geometry +0+20 -composite -bordercolor black -border 1 result1.png
Here I have created your white image of size 600x700 and composited your red image 50 pixels in x and y down and to the right. Then I set the gravity to south and composite the blue image up 20 pixels from the bottom. I have added black border so it is easier to see the image boundary.
Alternately, you can add an offset to -extent with negative values to shift the white relative to the red. That way you do not have to create the first white image and composite the red onto it.
convert xc:red[350x500] -extent "600x700-50-50" xc:blue[350x150] -gravity south -geometry +0+20 -composite -bordercolor black -border 1 result2.png
But unfortunately, the offset on the extent seems to trim (the height of) the red image. So I do not think this is an effective solution.
来源:https://stackoverflow.com/questions/44128387/imagemagick-command-geometry-not-working