I have a large image of sprites
And each set of 16 color sprites is split with different background colors as seen in the above image.
As Im doing now, I manually split them and then I use this command after decreasing it to 16 colors with infranview.
convert image.bmp -crop 32x32 image-%02d.bmp
what i want to know is, is there a simpler way to do this via image magick?
Command line help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Command line help
You can do it all in IM with -colors
or you can create a color table image of only the 16 specific colors you want and use -remap as
see http://www.imagemagick.org/Usage/quantize/#remap
Code: Select all
convert image.bmp +dither -colors 16 -crop 32x32 image-%02d.bmp
or you can create a color table image of only the 16 specific colors you want and use -remap as
Code: Select all
convert image.bmp +dither -remap colortable.gif -crop 32x32 image-%02d.bmp
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Command line help
A simpler way to do what?joexv wrote:what i want to know is, is there a simpler way to do this via image magick?
Only the top 1024 rows are relevant. "-crop x1024+0+0" will remove the stuff at the bottom. There are 10 panels across the image but the width is not divisible by 10. However, "-crop 10x8@" will chop it into panels. Then we can chop each panel into 3x4 sprites with "-crop 3x4@".
Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage p-%03d.png
We can make all sprites 32x32 pixels:
Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage -define distort:viewport=32x32+0+0 -filter box -distort SRT 1,0 p-%03d.png
Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage -define distort:viewport=32x32+0+0 -filter box -distort SRT 1,0 +dither -colors 15 p-%03d.png
snibgo's IM pages: im.snibgo.com
Re: Command line help
Im looking for a simpler wayt o split the image up by their color palette.snibgo wrote:A simpler way to do what?joexv wrote:what i want to know is, is there a simpler way to do this via image magick?
Only the top 1024 rows are relevant. "-crop x1024+0+0" will remove the stuff at the bottom. There are 10 panels across the image but the width is not divisible by 10. However, "-crop 10x8@" will chop it into panels. Then we can chop each panel into 3x4 sprites with "-crop 3x4@".
"identify p*.png" tells us each sprite is 31 or 32 high, and 32 wide. Most sprites have 16 or fewer colours. A few have more.Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage p-%03d.png
We can make all sprites 32x32 pixels:
We can reduce each one to 16 colours with "-colors 15". (Don't ask me why "15".)Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage -define distort:viewport=32x32+0+0 -filter box -distort SRT 1,0 p-%03d.png
After cropping into panels, you might want to do something about bad pixels at edges, caused by the panels being badly placed in the large image.Code: Select all
convert ..\sprites.png -crop x1024+0+0 -crop 10x8@ -crop 3x4@ +repage -define distort:viewport=32x32+0+0 -filter box -distort SRT 1,0 +dither -colors 15 p-%03d.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Command line help
Please explain further. There is only one color palette in any given image. Do you want to make one image per each color in the color palette?joexv wrote: Im looking for a simpler wayt o split the image up by their color palette.