Tile smaller image over a background with offsets?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
grape
Posts: 6
Joined: 2018-10-02T13:15:03-07:00
Authentication code: 1152

Re: Tile smaller image over a background with offsets?

Post by grape »

fmw42 wrote: 2018-10-03T16:13:33-07:00 In IM 7 on Unix, this seems to do what I think you want.

Code: Select all

WxH=`magick stars.jpg -format "%wx%h" info:`
ww=`echo "$WxH" | cut -dx -f1`
hh=`echo "$WxH" | cut -dx -f2`
centx=`magick xc: -format "%[fx:round($ww/2)]" info:`
xx=$((centx))
yy=0
i=0
echo "$hh; $ww; $centx; $xx; $yy;"
magick stars.jpg result.png
while [ $xx -lt $ww -a $yy -lt $hh ]; do
echo "$xx; $yy;"
magick result.png \( cat.png +repage -resize 50% \) -gravity northwest -geometry +${xx}+${yy} -compose over -composite result.png
echo ""
i=$((i+1))
xx=`magick xc: -format "%[fx:$i%2==1?($xx-100):($xx+100)]" info:`
yy=$((yy+100))
done
magick result.png stars_cat3.jpg
rm -f result.png
Image
O WOW!! That is very comprehensive. Thank you so much for taking the time to help me out here. You really know your way around command line and IM. This is friggin awesome. Thank you so much
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tile smaller image over a background with offsets?

Post by fmw42 »

I wrote:

Code: Select all

while [ $xx -lt $ww -a $yy -lt $hh ]; do
But since you are constraining your positioning width-wise already, the width test could be removed so that the command is just on the height.

Code: Select all

while [ $yy -lt $hh ]; do
Post Reply