Pack Sprites from command line

Hello everyone,

I am trying to pack sprite from these two images:

pear cloud

I can achieve this using GMIC GIMP plugin, but I would really prefer CLI option, so I have tried to replicate the process using the following commands:

gmic background.png pear.png cloud.png pack_sprites 3,25 -o background_rendered.jpg

gmic background.png pear.png cloud.png pack_sprites 3,25 -o background_rendered.png

The problem is that I end with following results:

background_rendered.jpg (only black background, CMYK color space)


background_rendered.png (white background and nothing else)

I would like to end up with the png image (preferably with transparent background), similar to the one I can generate in GIMP.

Thank you in advance!

Hi @Tehni and welcome!

I am not especially skilled in using g’mic CLI-wise;
but if you can achieve what you are after using
gimp-g’mic – why not let gimp-g’mic show you the
command line(s) necessary?

Have fun!
Claes in Lund, Sweden

From the reference manual, “[the background image’s] last channel must be a binary mask whose zero values represent potential locations for drawing the sprites.”

In other words, it should either be a grayscale that is all zeros, or an RGBA that is all opaque.

Similarly for the sprites: “Their last channel must be a binary mask that represents the sprite shape (i.e. a 8-connected component).”

The example in the reference manual uses to_rgba on everything … but my understanding can’t be quite right because in the example the circle doesn’t get filled with sprites. But perhaps that insight will get you pointed in the right direction.

This post discusses on how to get the command line output:

Command line :slight_smile:

gmic update background.jpg pear.png cloud.png to_rgba fx_pack_sprites[-1,-2] 5,25,3,1,7,0,{w#0},{h#0} blend[-1,-2] alpha o background_rendered.png

background.jpg

background_rendered.png

3 Likes

Thank you very much, works like magic! And also thanks to all the others for the answers :slightly_smiling_face:

Just one more clarification - do I understand it corretly that if I want to modify it for 3 or more images I just add the input and insert the ‘additional number parameter’ into the command?

gmic update background.jpg pear.png cloud.png XXX.png to_rgba fx_pack_sprites[-1,-2,-3] 5,25,3,1,7,0,{w#0},{h#0} blend[-1,-2] alpha o background_rendered.png