Page 1 of 1

Command line help

Posted: 2015-08-09T13:48:29-07:00
by joexv
I have a large image of sprites
Image

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?

Re: Command line help

Posted: 2015-08-09T14:12:44-07:00
by fmw42
You can do it all in IM with -colors

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
see http://www.imagemagick.org/Usage/quantize/#remap

Re: Command line help

Posted: 2015-08-09T15:13:45-07:00
by snibgo
joexv wrote:what i want to know is, is there a simpler way to do this via image magick?
A simpler way to do what?
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
"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.

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
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 +dither -colors 15 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.

Re: Command line help

Posted: 2015-08-15T12:35:45-07:00
by joexv
snibgo wrote:
joexv wrote:what i want to know is, is there a simpler way to do this via image magick?
A simpler way to do what?
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
"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.

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
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 +dither -colors 15 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.
Im looking for a simpler wayt o split the image up by their color palette.

Re: Command line help

Posted: 2015-08-15T12:52:11-07:00
by fmw42
joexv wrote: Im looking for a simpler wayt o split the image up by their color palette.
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?