The International Simutrans Forum

PakSets and Customization => General Resources and Tools => 3D Modeling => Topic started by: Andyh on July 28, 2020, 03:48:18 PM

Title: Combining PNG images
Post by: Andyh on July 28, 2020, 03:48:18 PM
I'm looking for some advice for an efficient way of combining a series of PNG images into a single image for the purpose of creating a PAK file.  It seems like this should be an easy task but I can't for the life of me figure how to do it.


I have a series of 8 separate images of a vehicle from all the required angles.  However, in every vehicle I've ever downloaded, the source images have been combined into a single neat, tiled PNG image.  I'm sure I could create such an image with a lot of messing around with layers and so forth in the GIMP, but I would like to be able to be able to do so quickly, repeatedly and reliably as I'm sure I'll need to go through multiple iterations of the PAK creation process to get everything right.  Does anyone know how to do this?  I feel that I must be missing something.
Title: Re: Combining PNG images
Post by: wlindley on July 28, 2020, 04:07:24 PM
You could use ImageMagick — if you're on any common Linux distribution, the commands 'convert' 'mogrify' and 'montage' should already be available and you can follow instructions at this article (https://superuser.com/questions/290656/combine-multiple-images-using-imagemagick).  Otherwise, install the free ImageMagick program (http://www.imagemagick.org/). 

Use 'convert' with either '-append' or '+append' for a row or column of images in one file.  Use 'montage' for a matrix.

If you have a script that builds your PNG images, append whatever command you wind up using (convert or montage) for automatic creation.
Title: Re: Combining PNG images
Post by: Leartin on July 28, 2020, 04:13:48 PM
That neat image file with several graphics on it is called a "spritesheet", or at least that's the term you should be looking for. Eg. https://codeshack.io/images-sprite-sheet-generator/ <-- online, drag single images in, get one spritesheet out.

Once you google "spritesheet generator", you'll find many tools for that task to download as well. Texturepacker (https://www.codeandweb.com/texturepacker) or SpriteSheetPacker (https://github.com/nickgravelyn/SpriteSheetPacker), for example.
I don't personally use any of these tools though, so I can't speak from experience.

Title: Re: Combining PNG images
Post by: Mariculous on July 28, 2020, 05:38:36 PM
The hints are good, but I'd like to show up a different angle.

In pak128.Britain-Ex, it seems quite common to render images in blender and leaving those as-is, that means split into different images.
Though, old images seem to be merged into a single one.

If you want to organise things, you may just create one folder per vehicle and put the images in there rather than merging them into a single png.
Not saying merging images is bad practice or something, it's up to you what you prefer, except if you are contribiuting to a pakset which strictly prefers a specific way, for sure.
Title: Re: Combining PNG images
Post by: Andyh on July 28, 2020, 07:48:44 PM
Thank you all for your ideas.  I use the Blender render script, and since it seems to be acceptable practice in the community I'm actually leaning towards Freahk's solution of not combining the images.  I would be happy not to have to do that extra step, but since it seemed so universal I thought I must be doing something wrong.
Title: Re: Combining PNG images
Post by: Mariculous on July 28, 2020, 08:25:15 PM
Well pak128.britain-ex's new workflow does not involve combining those. It's as simple as "render it and you're done"

I have no idea about other paksets though.
Title: Re: Combining PNG images
Post by: Leartin on July 29, 2020, 07:41:36 AM
Quote from: Freahk on July 28, 2020, 08:25:15 PM
I have no idea about other paksets though.
In Non-render paksets, you'd work on the images directly. Anything you add in one rotation, you'd have to add in all other rotations, and it would be quite a hassle if everything was seperated.
Older render images had to do cleanup of the edges, since semitransparency wasn't a thing. Since you had to start up 2D software and open all images anyway, merging wasn't weird. But if you don't need to touch the output anymore, sticking them in a folder and never looking at them is fine.
Title: Re: Combining PNG images
Post by: RealAmerican1776 on July 30, 2020, 02:39:05 AM
What I do is grab a file off of the Pak.whatever-your-using github page and use that as a template. I then keep the template for further use. It makes things so much simpler later on. For example, I am redoing my snowy roads on my Pak256.America-Ex. I am using my dirt road blender file as a basis and then later just replace the dirt road with something else like cobblestone.