Resize-bend-resize script

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
darkfrei
Posts: 15
Joined: 2018-01-16T11:47:26-07:00
Authentication code: 1152

Resize-bend-resize script

Post by darkfrei » 2018-11-13T09:16:15-07:00

Hi all!

I know how resize, but what tool I can use for bending?

Now I need make a lot of images like that (magenta is for position):
Original image for example
Image
image-01.png

Resize to 200x200
Image
image-02.png (200x200 px)

Bend this image to (it's also 200x200)
Image
image-03.png (200x200 px)

And resize it back to 20x20
Image
image-04.png (20x20 px)
Last edited by darkfrei on 2018-11-13T10:45:31-07:00, edited 2 times in total.

User avatar
GeeMack
Posts: 698
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Resize-bend-resize script

Post by GeeMack » 2018-11-13T09:30:36-07:00

darkfrei wrote:
2018-11-13T09:16:15-07:00
I know how resize, but what tool I can use for bending?
You can use "-distort arc" to accomplish that. This command will do the 90° bend...

Code: Select all

convert input.png -background none -virtual-pixel none -distort arc "90 45 200 0" -shave 1 result.png
Learn more about using "-distort arc" to make bends and curves at THIS link.

You may want to use "-scale" rather than "-resize" to scale up before the distort to avoid aliasing. If you're using IM version 7 use "magick" instead of "convert".

darkfrei
Posts: 15
Joined: 2018-01-16T11:47:26-07:00
Authentication code: 1152

Re: Resize-bend-resize script

Post by darkfrei » 2018-11-13T10:24:21-07:00

Thanks, GeeMack!

I've also found another link http://www.imagemagick.org/Usage/mapping/#circlar_arc and trying to undertand it.

darkfrei
Posts: 15
Joined: 2018-01-16T11:47:26-07:00
Authentication code: 1152

Re: Resize-bend-resize script

Post by darkfrei » 2018-11-13T10:53:35-07:00

This part is too complicated:

Code: Select all

magick image-02.png -background none ^
 -gravity East -extent 400x200 ^
 -virtual-pixel none -distort Arc 180 image-180.png
Here I take image-02.png (200x200 px), add another 200 pixels on the left (west) side.
But -distort makes this picture as 456x229 px :shock:

Image
image-180.png (456x229)

darkfrei
Posts: 15
Joined: 2018-01-16T11:47:26-07:00
Authentication code: 1152

Re: Resize-bend-resize script

Post by darkfrei » 2018-11-13T13:36:45-07:00

Looks amazing! Exactly what I want. For 32 pixels here is distort "...320...".

Code: Select all

magick "Input/*.png" ^
 -scale 1000%% ^
 -background none ^
 -virtual-pixel none ^
 -distort arc "90 45 320 0" -shave 1 ^
 -scale 10%% ^
 Output/bend_90_%%04d.png
pause

darkfrei
Posts: 15
Joined: 2018-01-16T11:47:26-07:00
Authentication code: 1152

Re: Resize-bend-resize script

Post by darkfrei » 2018-11-14T11:28:32-07:00

Another question, but for the same project:
How to make from one image a lot of them but with shift? By paint dot net it calls "panelling", but it's very big work.
So I want to make from this picture 32x32:
Image

this spritesheet with 32 elements, every sprite was shifted one pixel to the right.
Image

User avatar
GeeMack
Posts: 698
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Resize-bend-resize script

Post by GeeMack » 2018-11-14T11:33:18-07:00

darkfrei wrote:
2018-11-14T11:28:32-07:00
this spritesheet with 32 elements, every sprite was shifted one pixel to the right.
Try this...

Code: Select all

magick sprite1.png -duplicate 31 -roll +%[fx:t]+0 -append +repage sprites32.png

Post Reply