In Imagemagick what is the opposite of crop. Add padding to one side of an image -


i know extend , gravity. have image , want increase canvas size 400x400 , want take existing image , place @ specific x , y in canvas. have specific values, need ability move image there.

here example.

 width = 52   page.x = 158  400 - width - page.x = 190   height = 107  page.y = 146  400 - height - page.y = 147 

in example image needs resize 52x107 400x400 , image needs start @ 158x146 in need 400x400 canvas.

if not distorting original 52x107 image, might simple -repage +{left}+{top}.

# given 52x107 image. convert -size 52x107 xc:orange 52x107.png 

52x107.png

# create blank canvas act padding. convert -size 400x400 xc:lime \( 52x107.png -repage +158+146 \) -flatten out.png 

out.png

in example image needs resize 52x107 400x400 , image needs start @ 158x146 in need 400x400 canvas.

however sounds do want resize small image 400x400, , adjust offset w/ padding.

# using rose: example convert -size 400x400! xc:lime \         \( rose: -resize 400x400! -repage +158+146 \) \         -flatten out2.png 

out2.png

... or ... attempting more dynamic

offset=$(identify -format '+%[fx:(400-w)/2]+%[fx:(400-h)/2]' rose:) convert rose: -repage $offest \         \( +clone -resize 400x400! -repage +0+0 \) \         -swap 0,1 -flatten out3.png 

out3.png

but, perhaps, i'm not understanding op question.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -