Creating outlines with GIMP

Moderator: Jason Petho

Post Reply
User avatar
Schlonz
Posts: 142
Joined: Sun Aug 26, 2007 10:10 am

Creating outlines with GIMP

Post by Schlonz »

Hi all,

I would like to show you a quick way to create outline files (.BIT) with GIMP 2.10.38.
Maybe this has been described before, but if so, I haven't found anything.

- open the Upxxxxxx.BMP (without shadows) with GIMP
Image

- Select -> By Color -> click on the background
- Select -> Border (1px, Border style: hard) -> OK
Image

- Select -> Invert
- Edit -> Clear (or press DEL key)
Image

- File -> Export As... -> in this example Op149019.bmp
- File -> Close view -> Discard Changes
- File -> Open Recent -> select the Op149019.bmp
- use Bucket Fill (white) to remove the rectangular "frame" around the image
- use Bucket Fill (black) to change the color of the 6 seperate unit outlines
Image

Image

- Image -> Mode -> Indexed... -> Use black and white (1-bit) palette
- File -> Overwrite Op149019.bmp
- File -> Quit -> Discard Changes
- now rename the file from BMP to BIT and your done
Image

If you're used to this procedure, you'll create perfect BIT file in 2 minutes or less.
"I've got a plan so cunning, you could put a tail on it and call it a weasel."
- Blackadder
User avatar
Schlonz
Posts: 142
Joined: Sun Aug 26, 2007 10:10 am

Re: Creating outlines with GIMP

Post by Schlonz »

Ingame view

Image
"I've got a plan so cunning, you could put a tail on it and call it a weasel."
- Blackadder
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Oh, I had missed this post, thanks a ton, Schlontz! I will try to see if GIMP Python API supports these features you describe, if so, I can write a tool that integrates to GIMP Menu. "Create BIT Outlines", in one click. Wish me luck!
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Hello Schlonz

I had not done any Gimp Python coding for a few years, it is a bit peculiar environment to debug, especially, but here we go. Good practice!

Download the zip file, unzip, and place cslegion_create_3D_unit_bit_file.py at your Gimp plug-ins folder, which may be hidden ie. you need to unhide folders in your File Explorer.

My GIMP plug-ins are at C:\Users\[MYUSERNAME]\AppData\Roaming\GIMP\2.10\plug-ins

Once you fire up, you should find a new entry at your Tools folder, not all of these, just the 5a entry.
  • Open a unit image and run it. It saves a BIT file in the same folder having changed the name with *_BIT.bmp pattern.
  • Hit Undo once to restore your original image.
Gimp5a.jpg
Gimp5a.jpg (232.48 KiB) Viewed 249 times

Go to your image folder, open a Power Shell command promp there, and paste and run this command to rename the bmp files to bit files:

Code: Select all

Dir *_BIT.bmp | Rename-Item -NewName { $_.Name -replace '_BIT\.bmp$', '.bit' }

Should this work (I haven't really had time to test this in game), let me know. I can then code the 5b variant which would read all 3xs files in a temp folder and create a *_BIT.bmp out of all of them. That would truly save time, if you have plenty of outlines to create.
Attachments
cslegion_create_3D_unit_bit_file.zip
(1.9 KiB) Downloaded 6 times
Last edited by Crossroads on Wed Jan 15, 2025 6:57 pm, edited 6 times in total.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Actually, to properly rename _BIT.bmp files this should do it:

Code: Select all

Dir Up*_BIT.bmp | Rename-Item -NewName { $_.Name -replace '^Up', 'Op' -replace '_BIT\.bmp$', '.bit' }
Dir Up*_BIT.bmp selects all the files that match that pattern, and in addition to renaming the file type pattern match, "Up" is replaced by "Op"

Up249031_BIT.bmp -> Op249031.bit
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Note that I haven't tested this in-game. GIMP Python API does not allow any parameters to Export function. I did change the Image mode to Indexed, but it still might not export it properly.

If that is the case, you can export again, manually, since the outline image remains in GIMP until Undone.

Let me know how this works for you!
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Schlonz wrote: Sun Dec 15, 2024 11:45 am If you're used to this procedure, you'll create perfect BIT file in 2 minutes or less.
I uploaded a newer zip file to my post, this should shave off a few tenths from the process.

Procedure duration is now down to 2 seconds, more or less :mrgreen:
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Schlonz
Posts: 142
Joined: Sun Aug 26, 2007 10:10 am

Re: Creating outlines with GIMP

Post by Schlonz »

I just did a test with the "old" version, worked like a charm....excellent.
"I've got a plan so cunning, you could put a tail on it and call it a weasel."
- Blackadder
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Schlonz wrote: Wed Jan 15, 2025 4:40 pm I just did a test with the "old" version, worked like a charm....excellent.
Excellent indeed! Thank you for providing the step-by-step guideline for us GIMP users, it was not too difficult to do the Python code with that available.

Paul "papalarazu" Hill who created the unit image templates for Vietnam used PhotoShop Pro as his graphics editor of choise. PSP comes with a proprietary script language as well, Paul created scripts for first turning the old "shadow mesh" unit images to use the "shadow blob" standard we now use, then for removing those blobs for the 3Dxs versions, and indeed for creating outlines from the 3Dxs versions. I am not familiar with PSP scripting language, and was very happy to use his for the little need that I had.

But, as GIMP user, this is much better. I will create the folder version of this over the weekend, the difference being that you would simply choose a folder with 3Dxs images, and the Menu command would automatically convert outlines from all bitmaps there. Quite useful if there's a larger number of images to convert from.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Crossroads wrote: Wed Jan 15, 2025 4:36 pm Procedure duration is now down to 2 seconds, more or less :mrgreen:
Well no, it isn't. There's the manual step to rename the created bmp to bit.

But since I have Python available inside GIMP, I should be able to do the file rename with the Python "os" library import even if I can't export the file properly under the GIMP API.

And I was. Added a timer for the fun of it. Now it truly clocks under two seconds:

Gimp5a_v2.jpg
Gimp5a_v2.jpg (279.9 KiB) Viewed 193 times

Do note that there really isn't much error handling. If you for instance run this again, and the bit file already exists, it fails I think. Look for the outlined console message declaring steps 1 to 10 all succesful.

Version 2 of the GIMP script available below:
Attachments
cslegion_create_3D_unit_bit_file.zip
(2.18 KiB) Downloaded 3 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
User avatar
Crossroads
Posts: 18150
Joined: Sun Jul 05, 2009 8:57 am

Re: Creating outlines with GIMP

Post by Crossroads »

Crossroads wrote: Wed Jan 15, 2025 6:00 pm I will create the folder version of this over the weekend, the difference being that you would simply choose a folder with 3Dxs images, and the Menu command would automatically convert outlines from all bitmaps there. Quite useful if there's a larger number of images to convert from.
Here you are, Schlonz. The folder version suggest C:\Temp as the working folder, as I am lazy. You can select other folder as well there.

I noticed GIMP does not like the old 8bit color depth unit images, but likelyhood of having those in 3Dxs versions should be very low. We prefer 24bit versions, so I won't try to figure out how to fix this. Likely, I could add a first step that creates a duplicate with proper Image mode, but I don't have the time at the moment.

This zip file with latest versions for both Create Outline GIMP scripts. Let me know if you spot anything!
Attachments
plug-ins.zip
(4.19 KiB) Downloaded 3 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.00.03 Remastered Edition (May 20, 2025)
CS: Middle East 1948-1985 < v3.00.03 Remastered Edition (May 20, 2025)
Post Reply

Return to “Mods and Scenarios”