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):

sydney

jet2.png (128x129):

jet2

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:

result

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

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -