Overlaying two images with automatic resize using ImageMagick -
is there way automatically resize overlay image according background size when overlaying images using imagemagick? using following code now:
composite overlay.jpeg background.jpeg result.jpeg
the problem overlay , background of different sizes, , i'd resize overlay accordingly (keeping aspect ratio) , place center. there way that?
first of all, overlay , background not need same size composite work. example, given these 2 images:
sydney.png (352x288):
jet2.png (128x129):
try following commands:
convert -size 352x288 -composite sydney.png jet2.png -geometry 64x64+176+144 -depth 8 test.png convert -size 352x288 -composite sydney.png jet2.png -geometry 32x32+176+144 -depth 8 test.png
-size
specifies output image dimensions-geometry
specifies dimensions , location of foreground
this first command:
edit
here's bash script in 1 line:
#!/bin/bash if [ -z "$3" ] echo "usage: $0 background.png foreground.png output.png" exit 1 fi bg_size=`identify -format '%wx%h' "$1"` convert -size $bg_size -composite "$1" "$2" -geometry $bg_size+0+0 -depth 8 "$3"
Comments
Post a Comment