So, apparently I have a chest image that I want to extend. I use ImageMagick 6.9.3-4 on Windows, but I'd also appreciate having the Linux Bash syntax for the command as well. The chest image i'm testing with is a strip of 576x384 for a video game, with each sprite being 48x48. Here's what I need to do.
For the image, I need to crop it by '6xH', with H being the height of the input image, but for each frame that is a multiple of 3 (assuming the first frame is frame 1), I need to clone it X times, and then re-append the image horizontally to extend the length of the chest. For the example I cloned the frames twice. On the left is the original.
Split and extend chest sprite.
-
- Posts: 27
- Joined: 2016-03-11T07:27:11-07:00
- Authentication code: 1151
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Split and extend chest sprite.
Sorry, but I do not understand your description of what you want to happen. Perhaps you can provide the full image that you start with and explain in more detail with diagrams if possible. When you say H do you mean the height of 384 or 48?
If you know how to clone it twice, what is the code you used? Can you not repeat it again for the third or X times?
If you know how to clone it twice, what is the code you used? Can you not repeat it again for the third or X times?
-
- Posts: 27
- Joined: 2016-03-11T07:27:11-07:00
- Authentication code: 1151
Re: Split and extend chest sprite.
For H, I mean the height of the input image, usually it's 384 but it might be different in some cases.fmw42 wrote: ↑2017-01-22T11:41:46-07:00 Sorry, but I do not understand your description of what you want to happen. Perhaps you can provide the full image that you start with and explain in more detail with diagrams if possible. When you say H do you mean the height of 384 or 48?
If you know how to clone it twice, what is the code you used? Can you not repeat it again for the third or X times?
To clone it twice, I had used Game Maker's sprite editor, which is a GUI program, not ImageMagick.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Split and extend chest sprite.
So please provide the original 576x384 frame that you want to access or one of the 48x48 pieces that you want extended.
What do you mean by "a frame that is a multiple of 3"?
Sorry, more detail or a diagram would be helpful, since I still do not understand the problem.
What do you mean by "a frame that is a multiple of 3"?
Sorry, more detail or a diagram would be helpful, since I still do not understand the problem.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Split and extend chest sprite.
I downloaded the left image. It consists of a chest with black space on the left, an area of shadow on the right and 5 'bands' making up the chest proper.
left edge, one band, center lock, another band, and right edge. A total of 7 thin vertical segments in the image
I gather you want to clone the two thin bands to make 3 of them, on each side of the center lock to generate the 'longer' chest shown in the right image?
The image with is 48 pixels wide, whcih does not divide well into 7 segments. Attempts to divide in 7 'near equal' segments does not divide the image nicely.
convert left.png -crop 7x1@ show:
Triming the left edge does make it divide up better, but right edge is not good.
convert left.png -trim -crop 6x1@ show:
So different tack... Using 'strip cropping' to extract 'slices' of the image
http://www.imagemagick.org/Usage/crop/#crop_strip
using a view I find positions to divide the image into 5 parts left, thin band, lock, thin band, and right
The each vertical segment start at x = 0, 11, 18, 27, 34 and are of widths 11, 7, 9, 7, 14 pixels
Here I divide the image into 5 and then re-append them to get original image
This duplicates the 2 thin 7 segment bands. -- effectively producing your second (right) image of an extended chest (image 76 pixels width)
Adjust the duplication counts (adding 14 pixels over 2 bands for each extension) as desired.
There are probably other solutions, but I believe that is what you are looking for.
left edge, one band, center lock, another band, and right edge. A total of 7 thin vertical segments in the image
I gather you want to clone the two thin bands to make 3 of them, on each side of the center lock to generate the 'longer' chest shown in the right image?
The image with is 48 pixels wide, whcih does not divide well into 7 segments. Attempts to divide in 7 'near equal' segments does not divide the image nicely.
convert left.png -crop 7x1@ show:
Triming the left edge does make it divide up better, but right edge is not good.
convert left.png -trim -crop 6x1@ show:
So different tack... Using 'strip cropping' to extract 'slices' of the image
http://www.imagemagick.org/Usage/crop/#crop_strip
using a view I find positions to divide the image into 5 parts left, thin band, lock, thin band, and right
The each vertical segment start at x = 0, 11, 18, 27, 34 and are of widths 11, 7, 9, 7, 14 pixels
Here I divide the image into 5 and then re-append them to get original image
Code: Select all
convert left.png \
\( -clone 0 -crop 11x0+0+0 \) \
\( -clone 0 -crop 7x0+11+0 \) \
\( -clone 0 -crop 9x0+18+0 \) \
\( -clone 0 -crop 7x0+27+0 \) \
\( -clone 0 -crop 14x0+34+0 \) \
-delete 0 +repage +append show:
Code: Select all
convert left.png \
\( -clone 0 -crop 11x0+0+0 \) \
\( -clone 0 -crop 7x0+11+0 -duplicate 2 \) \
\( -clone 0 -crop 9x0+18+0 \) \
\( -clone 0 -crop 7x0+27+0 -duplicate 2 \) \
\( -clone 0 -crop 14x0+34+0 \) \
-delete 0 +repage +append extended_chest.png
There are probably other solutions, but I believe that is what you are looking for.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/