I want to go from this:
![Image](https://picload.org/image/rllrprgw/quarter.png)
to this:
![Image](https://picload.org/image/rllrprgi/full.png)
However I can't think of a way to rotate and append (while exanding the canvas without further instructing just how much) how exactly this might work.
Any help is appreciated.
-Rye-
Using "-distort SRT" allows for modifying the viewport size, rotating images on a particular center point, and finishing by moving that center point to another particular location all in one operation. Find out more about "-distort SRT" at THIS link.
Code: Select all
convert quarter.png -duplicate 3 -background none -virtual-pixel none ^
-set option:distort:viewport "%[fx:w*2]x%[fx:h*2]" ^
-distort SRT "%[w],0 1 %[fx:t*90] %[w],%[h]" +repage -flatten wholecircle.png
Code: Select all
convert quarter.png -trim +repage -write mpr:img \
\( mpr:img -flip \) +swap -append \
\( -clone 0 -flop \) +append \
result.png
Another straightforward approach would be to duplicate the image, rotate one of the pair as necessary, and append them horizontally to make a half circle. Then duplicate that, rotate one of that pair so appending them vertically creates the whole circle. It still uses the "-distort SRT" operation I mentioned in my previous comment. That allows for conditionally rotating, scaling, etc., depending on and individual image's position in the stack. This would create the result in your example...
Code: Select all
convert quarter.png ^
+duplicate -distort SRT "%[fx:t?-90:0]" +append ^
+duplicate -distort SRT "%[fx:t?0:180]" -append wholecircle.png
Code: Select all
convert quarter.png ^ +duplicate -distort SRT "%[fx:t?-90:0]" +append ^ +duplicate -distort SRT "%[fx:t?0:180]" -append whole.png
Code: Select all
[b]for %%x in (*png) do [/b]convert %%x ^ +duplicate -distort SRT "%[fx:t?-90:0]" +append ^ +duplicate -distort SRT "%[fx:t?0:180]" -append 0-%%x
Code: Select all
Why the [b] and [/b]?
Code: Select all
You have ^ characters that are not at the end of lines. Why?
The first thing I notice is you're using double percent "%%" signs on your loop variable like "%%x", and for the FX expressions in the IM command you only have single percent "%" signs like "%[fx:t?-90:0]". If you're running that code in a BAT script they all have to be double percent marks "%%". If you're running it from a command line they should all be singles "%".Rye wrote: ↑2017-03-09T13:59:14-07:00When I try and modify it like this (as I'm a windows user.. sorry for not mentioning):the result images are... blank... any ideas on why this is ?Code: Select all
[b]for %%x in (*png) do [/b]convert %%x ^ +duplicate -distort SRT "%[fx:t?-90:0]" +append ^ +duplicate -distort SRT "%[fx:t?0:180]" -append 0-%%x
The code should still for, even if looped, right ?
Code: Select all
convert quarter.png -virtual-pixel mirror -set option:distort:viewport "%[fx:w*2]x%[fx:h*2]+0+%[fx:h]" -filter point -distort SRT 0 x.png
I hadn't considered setting the geometry within the viewport setting. Thanks for mentioning that. I tried "-distort affine ..." and came up with a pretty simple method, too. It's similar to your example in that it uses "-virtual-pixel mirror" to get the dupes and mirrors, and gets there by sliding the image to a new location in the viewport.
Code: Select all
convert quarter.png -set option:distort:viewport "%[fx:w*2]x%[fx:h*2]" ^
-filter point -virtual-pixel mirror -distort affine "0,%[h] 0,0" circle.png