Page 1 of 1

SOLVED: -rotate and distort:viewport

Posted: 2014-03-19T09:34:45-07:00
by GreenKoopa
I'm getting a white box I hadn't expected. Does anyone know why? Here I am attempting to create a tiled background, then composite an image on top. This is just enough of a larger command to demonstrate the issue.

: unexpected white box
convert -size 1x1 xc:blue ^
-filter point -virtual-pixel tile -define distort:viewport=250x150+0+0 -distort SRT 0 +repage ^
( rose: -rotate 10 -geometry +50+50 ) -composite ^
out_1.png
Image

: shows size of white box to be 250x150
convert -size 1x1 xc:blue ^
-filter point -virtual-pixel tile -define distort:viewport=250x150+0+0 -distort SRT 0 +repage ^
+duplicate -append +duplicate +append ^
( rose: -rotate 10 -geometry +50+50 ) -composite ^
out_2.png
Image

: works when rose is not rotated
convert -size 250x150 xc:blue ^
-filter point -virtual-pixel tile -define distort:viewport=250x150+0+0 -distort SRT 0 +repage ^
( rose: -geometry +50+50 ) -composite ^
out_3.png
Image

: works when background is not tiled
convert -size 250x150 xc:blue ^
( rose: -rotate 10 -geometry +50+50 ) -composite ^
out_4.png
Image

ImageMagick 6.8.8-1 Q16 x64 on Windows 7

EDIT: Subject

Re: placing an image on a tiled background

Posted: 2014-03-19T09:52:03-07:00
by Bonzo
Add a background to your rotate:

Code: Select all

convert -size 1x1 xc:blue ^
-filter point -virtual-pixel tile -define distort:viewport=250x150+0+0 -distort SRT 0 +repage ^
+duplicate -append +duplicate +append ^
( rose: -background transparent -rotate 10 -geometry +50+50 ) -composite ^
out_2.png
But there could be other problems with the code causing the large box!

Re: placing an image on a tiled background

Posted: 2014-03-19T10:28:26-07:00
by GreenKoopa
Thanks Bonzo. Alternatively, a +define distort:viewport before rotating worked.

Re: placing an image on a tiled background

Posted: 2014-03-19T11:07:57-07:00
by GreenKoopa
I got it working!

output image

Code: Select all

convert ^
-size 106x106 xc:rgb(246,245,229) ^
-stroke none ^
-fill rgb(68,94,109) -draw "circle 52.5,52.5 1,52.5" ^
-fill rgb(246,245,229) -draw "rectangle 0,43 105,62" ^
-write mpr:screw +delete ^
-size 95x1 xc:rgb(76,117,142) -size 10x1 xc:rgb(246,245,229) +append ^
-virtual-pixel tile -define distort:viewport=3770x2880+0+0 -distort SRT 0 +repage ^
-bordercolor rgb(76,117,142) -border 10x0 -bordercolor white -border 13x0 ^
-fill rgb(246,245,229) -draw "rectangle 373,700 3442,2879 ellipse 1907.5,899 600,600 199,341" ^
-fill rgb(76,117,142)  -draw "rectangle 413,740 3402,2879 ellipse 1907.5,899 560,560 196,344" ^
-fill rgb(246,245,229) -draw "rectangle 433,760 3382,2879 ellipse 1907.5,899 540,540 195,345" ^
( +clone -flip ) -append ^
+define distort:viewport -virtual-pixel Edge -compose Over ^
( mpr:screw -distort SRT 20  -geometry +483+809   ) -composite ^
( mpr:screw -distort SRT 120 -geometry +3228+809  ) -composite ^
( mpr:screw -distort SRT 60  -geometry +483+4844  ) -composite ^
( mpr:screw -distort SRT 160 -geometry +3228+4844 ) -composite ^
-quality 90 PNG24:out.png

Re: placing an image on a tiled background

Posted: 2014-03-19T21:35:36-07:00
by GreenKoopa
In conclusion, I didn't realize that -rotate used the distort:viewport setting. Handy to know.

convert -define distort:viewport=100x80-10-10 rose: -rotate 10 out_5.png

Re: placing an image on a tiled background

Posted: 2014-03-19T22:07:22-07:00
by fmw42
GreenKoopa wrote:In conclusion, I didn't realize that -rotate used the distort:viewport setting. Handy to know.

convert -define distort:viewport=100x80-10-10 rose: -rotate 10 out_5.png
That is new to me. Perhaps -rotate angle is now an alias for -distort SRT angle?