MOD: Icons Directional(but shape outlined black)

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
DmitriyBlade
Posts: 93
Joined: Mon Dec 20, 2021 3:22 pm
Location: Russia

MOD: Icons Directional(but shape outlined black)

Post by DmitriyBlade »

Shape of icons outlined with black line to better visualize battlefield

Download:
https://drive.google.com/file/d/11SLOfg ... drive_link
or
Directional.zip
(162.27 KiB) Downloaded 53 times
Unpack to Command Modern Operations\Symbols\Directional

Here is backup icons default(without outline) https://drive.google.com/file/d/1yhGUeO ... drive_link

DIY chatgpt code:

Code: Select all

from PIL import Image, ImageDraw
import os

# Input and output folder paths
input_folder = r'C:\Users\DmitriyBlade\Desktop\SMALL'
output_folder = r'C:\Users\DmitriyBlade\Desktop\Stylized(outline)'

# Create the output folder if it doesn't exist
if not os.path.exists(output_folder):
    os.makedirs(output_folder)

# Outline color (black)
outline_color = (0, 0, 0, 255)  # RGBA

# Outline width in pixels
outline_width = 4

# Process each image in the input folder
for filename in os.listdir(input_folder):
    if filename.endswith('.png'):
        # Open the image
        image_path = os.path.join(input_folder, filename)
        image = Image.open(image_path).convert("RGBA")
        
        # Create a new image with the same dimensions and a transparent background
        new_image = Image.new("RGBA", image.size, (0, 0, 0, 0))
        
        # Paste the original image onto the new image
        new_image.paste(image, (0, 0), image)

        # Create a draw object for the outline
        draw = ImageDraw.Draw(new_image)

        # Find the shape using the alpha channel
        shape_pixels = set()
        for x in range(image.width):
            for y in range(image.height):
                r, g, b, a = image.getpixel((x, y))
                if a > 0:
                    shape_pixels.add((x, y))

        # Draw the outline around the shape
        for x, y in shape_pixels:
            for dx in range(-outline_width, outline_width + 1):
                for dy in range(-outline_width, outline_width + 1):
                    if (x + dx, y + dy) not in shape_pixels:
                        draw.point((x + dx, y + dy), outline_color)

        # Save the result in the output folder
        output_path = os.path.join(output_folder, filename)
        new_image.save(output_path, format="PNG")
1.png
1.png (1012.92 KiB) Viewed 867 times
3.png
3.png (2.74 KiB) Viewed 867 times
air_fw_hostile.png
air_fw_hostile.png (1.99 KiB) Viewed 865 times
Last edited by DmitriyBlade on Sat Aug 19, 2023 6:30 am, edited 1 time in total.
Transient
Posts: 110
Joined: Sat Jul 23, 2022 12:02 pm

Re: Icons Directional(but shape outlined black)

Post by Transient »

Thank you so sooo much for this!

I really disliked the merging of the icons on the 64bit when units were in close proximity.
Overlordyuly
Posts: 4
Joined: Tue May 31, 2022 12:15 am

Re: MOD: Icons Directional(but shape outlined black)

Post by Overlordyuly »

HI can this be done with Stylized icons ?
DmitriyBlade
Posts: 93
Joined: Mon Dec 20, 2021 3:22 pm
Location: Russia

Re: MOD: Icons Directional(but shape outlined black)

Post by DmitriyBlade »

Overlordyuly wrote: Thu Nov 02, 2023 5:24 pm HI can this be done with Stylized icons ?
Install Python
https://www.python.org/downloads/

Open Command terminal (CMD)
pip install PIL

copy this code, change directory(input&output folder paths) according to yours,
input_folder = r'C:\Users\DmitriyBlade\Desktop\SMALL'
output_folder = r'C:\Users\DmitriyBlade\Desktop\Stylized(outline)'
copy data(stylized icons from CMO folder to input_folder)
save to desktop as 123.py
run 123.py
copy from output_folder to CMO folder


from PIL import Image, ImageDraw
import os

# Input and output folder paths
input_folder = r'C:\Users\DmitriyBlade\Desktop\SMALL'
output_folder = r'C:\Users\DmitriyBlade\Desktop\Stylized(outline)'

# Create the output folder if it doesn't exist
if not os.path.exists(output_folder):
os.makedirs(output_folder)

# Outline color (black)
outline_color = (0, 0, 0, 255) # RGBA

# Outline width in pixels
outline_width = 4

# Process each image in the input folder
for filename in os.listdir(input_folder):
if filename.endswith('.png'):
# Open the image
image_path = os.path.join(input_folder, filename)
image = Image.open(image_path).convert("RGBA")

# Create a new image with the same dimensions and a transparent background
new_image = Image.new("RGBA", image.size, (0, 0, 0, 0))

# Paste the original image onto the new image
new_image.paste(image, (0, 0), image)

# Create a draw object for the outline
draw = ImageDraw.Draw(new_image)

# Find the shape using the alpha channel
shape_pixels = set()
for x in range(image.width):
for y in range(image.height):
r, g, b, a = image.getpixel((x, y))
if a > 0:
shape_pixels.add((x, y))

# Draw the outline around the shape
for x, y in shape_pixels:
for dx in range(-outline_width, outline_width + 1):
for dy in range(-outline_width, outline_width + 1):
if (x + dx, y + dy) not in shape_pixels:
draw.point((x + dx, y + dy), outline_color)

# Save the result in the output folder
output_path = os.path.join(output_folder, filename)
new_image.save(output_path, format="PNG")
Post Reply

Return to “Mods and Scenarios”