Arrange image to circle
Arrange image to circle
Hi,
question,
how could I arrange multiple of these (named 001.png 002.png ... etc)
to something like this:
imgur.com/370e41f0-b0d2-49be-95f0-4672f039b489
using only imagemagick ?
- Thanks in advance.
question,
how could I arrange multiple of these (named 001.png 002.png ... etc)
to something like this:
imgur.com/370e41f0-b0d2-49be-95f0-4672f039b489
using only imagemagick ?
- Thanks in advance.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Arrange image to circle
Assuming you're in the directory containing the input images and that they're in the order you want them to appear in the output, a command like this would accomplish that task...
Code: Select all
magick *.png -gravity north -background none -extent 225x225 \
-virtual-pixel none -distort SRT "%[fx:t*360/n]" -flatten result.png
Re: Arrange image to circle
Ah nice !
Supposing I'd change from say 12 to maybe 36 or perhaps 48 dashes:
Can your code be simply adapted to that ?
Also, out of curiosity: What is a "virtual pixel" ?
Supposing I'd change from say 12 to maybe 36 or perhaps 48 dashes:
Can your code be simply adapted to that ?
Also, out of curiosity: What is a "virtual pixel" ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Arrange image to circle
That FX expression "%[fx:t*360/n]" tells IM to rotate each input image in the list, designated by the "t", multiplied by 360 degrees divided by "n", the number of images in the list. It will still evenly rotate the images even if adding more images to the list. Learn more about FX expressions at THIS link.
If you're using the same image multiple times, you can read it in once then duplicate it as many times as necessary.
Code: Select all
magick dash.png -duplicate 11 ...
When you rotate something there will be some areas outside the image that will come into view. The virtual-pixel setting instructs IM on how to handle those pixels. Learn more about it at THIS link.Also, out of curiosity: What is a "virtual pixel" ?
Re: Arrange image to circle
Ok, that makes sense.
Strange though however,
upon executing the command I get:
magick: invalid list of numbers '-distort' 't*360/nl]' at CLI arg 10 @ error/operation.c/LISimpleOperatorImage/2257
Nevermind, my mistake, your command needs the "%" escaped inside a bat file.
Works now. Perfect!
Strange though however,
upon executing the command I get:
magick: invalid list of numbers '-distort' 't*360/nl]' at CLI arg 10 @ error/operation.c/LISimpleOperatorImage/2257
Nevermind, my mistake, your command needs the "%" escaped inside a bat file.
Works now. Perfect!
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Re: Arrange image to circle
One More question (sorry for the double post, but I'm not sure this will be seen else)
Kind of semi related:
If I for example had a horizontal picture and wanted to bend it to a circle, like this:
How'd I go about that ? Transform it ?
Kind of semi related:
If I for example had a horizontal picture and wanted to bend it to a circle, like this:
How'd I go about that ? Transform it ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Arrange image to circle
This example command starts by creating a red-to-yellow gradient image 400 pixels wide by 20 pixels high. Then it adds a transparent border to the top and bottom. Then it uses a version of "-distort" to bend it into a circle...
Code: Select all
magick -size 400x20 gradient:red-yellow ^
-bordercolor none -border 0x10 -virtual-pixel none -distort arc 360 circle.png
Learn more about using the "-distort" operator to make arcs and circles at THIS link. Look a bit further down that page for instructions on "-distort polar" which can also be used to bend images into circles.
Re: Arrange image to circle
Hmm...
for %%x in (*.png) do magick %%x -distort arc 360 %%x_out.png
creates a "globe like" sphere,
How can I modify its inner part to be empty however ? Also, is there a way to force it to use a predefined canvas size ? (as far a possible)
Ok, this seems to be getting better:
Just out of curiosity: Could Imagemagick *in theory* also "un-distort* an image back from a circle to a horizontal line ?
for %%x in (*.png) do magick %%x -distort arc 360 %%x_out.png
creates a "globe like" sphere,
How can I modify its inner part to be empty however ? Also, is there a way to force it to use a predefined canvas size ? (as far a possible)
Ok, this seems to be getting better:
Code: Select all
for %%x in (*.png) do magick %%x -virtual-pixel Background -background transparent -distort Arc 360 %%x_out.png
Just out of curiosity: Could Imagemagick *in theory* also "un-distort* an image back from a circle to a horizontal line ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Arrange image to circle
There are additional arguments to the "-distort arc" operator that let you specify the inside and/or outside dimensions of the result. You can find that on the page I linked.
Well, sort of. Again, the page I linked shows how to use "-distort polar" and "depolar". That might get you part way there with varying quality of results.Just out of curiosity: Could Imagemagick *in theory* also "un-distort* an image back from a circle to a horizontal line ?
Re: Arrange image to circle
Sort of is good enough for me here
I doubt I'll ever need to go the reverse anyways.
Thanks. Worked out like a charm!
I doubt I'll ever need to go the reverse anyways.
Thanks. Worked out like a charm!
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Arrange image to circle
Yes. I often do this, though in the opposite order: from a circle to a line, then back to a circle. An example is at De-barrel distortion.Rye wrote:Just out of curiosity: Could Imagemagick *in theory* also "un-distort* an image back from a circle to a horizontal line ?
snibgo's IM pages: im.snibgo.com