SOLVED: -rotate and distort:viewport

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?".
Post Reply
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

SOLVED: -rotate and distort:viewport

Post 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
Last edited by GreenKoopa on 2014-03-19T21:37:33-07:00, edited 1 time in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: placing an image on a tiled background

Post 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!
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: placing an image on a tiled background

Post by GreenKoopa »

Thanks Bonzo. Alternatively, a +define distort:viewport before rotating worked.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: placing an image on a tiled background

Post 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
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: placing an image on a tiled background

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: placing an image on a tiled background

Post 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?
Post Reply