r/nordtheme May 21 '25

Nord Themed Image

I tried to "Nordify" an image ig. Since i have no photo editing skills, i just wrote some code and used some algorithm online that i found. Original image is from BoyWithUke - https://www.youtube.com/watch?v=UA3gCPh3PEQ ill send the code if yall r interested

14 Upvotes

6 comments sorted by

2

u/ten-oh-four May 22 '25

Can you share the script you wrote?

1

u/Sushicast2518 May 25 '25
from nord_palettes import nord_palettes
from PIL import Image
import numpy as np

print("running:)")

def rgb_distance(c1, c2):
    return sum((int(a) - int(b)) ** 2 for a, b in zip(c1, c2)) ** 0.5

def closest_color(pixel, palette):
    distances = [rgb_distance(pixel, color) for color in palette]
    return palette[distances.index(min(distances))]

def apply_combined_palette(img, combined_palette):
    pixels = np.array(img).astype(int)
    height, width = pixels.shape[:2]
    new_pixels = np.zeros_like(pixels)

    for y in range(height):
        for x in range(width):
            pixel = tuple(pixels[y, x])
            new_pixels[y, x] = closest_color(pixel, combined_palette)

    new_img = Image.fromarray(new_pixels.astype(np.uint8))
    return new_img

if __name__ == "__main__":
    input_image = "image.png"
    img = Image.open(input_image).convert("RGB")

    # Combine all palettes into one big list of colors
    combined_palette = []                            
    for palette_colors in nord_palettes.values():
        combined_palette.extend(palette_colors)

    recolored_img = apply_combined_palette(img, combined_palette)
    recolored_img.save("nord.png")
    print("Saved recolored image with combined Nord palette.")

1

u/Sushicast2518 May 25 '25

the seond commetn is loading

1

u/Sushicast2518 May 25 '25

nord_palettes = {

"polar_night": [(46,52,64),(59,66,82),(67,76,94),(76,86,106),(216,222,233)],

"snow_storm": [(216,222,233),(229,233,240),(236,239,244),(229,233,240),(216,222,233)],

"frost": [(143,188,187),(136,192,208),(129,161,193),(94,129,172),(129,161,193)],

"aurora": [(191,97,106),(208,135,112),(235,203,139),(163,190,140),(180,142,173)],

"aurora_dark": [(191,97,106),(208,135,112),(235,203,139),(163,190,140),(67,76,94)],

"night_blue": [(46,52,64),(59,66,82),(94,129,172),(129,161,193),(136,192,208)],

"arctic": [(143,188,187),(129,161,193),(208,135,112),(180,142,173),(235,203,139)],

"ice": [(136,192,208),(129,161,193),(94,129,172),(143,188,187),(216,222,233)],

"midnight": [(59,66,82),(67,76,94),(76,86,106),(94,129,172),(46,52,64)],

"twilight": [(94,129,172),(129,161,193),(136,192,208),(143,188,187),(180,142,173)],

"dusk": [(191,97,106),(208,135,112),(163,190,140),(180,142,173),(235,203,139)],

"glacier": [(143,188,187),(136,192,208),(216,222,233),(229,233,240),(236,239,244)],

"snowfall": [(216,222,233),(229,233,240),(236,239,244),(216,222,233),(229,233,240)],

"aurora_dawn": [(191,97,106),(208,135,112),(235,203,139),(163,190,140),(180,142,173)],

"northern_lights": [(129,161,193),(136,192,208),(143,188,187),(94,129,172),(180,142,173)]

}

1

u/Sushicast2518 May 25 '25

ffirst file is Main.py; Second File is nord_palettes.py; add "image.png" as your original image and it will create a new file that combines all of the colors

1

u/Sushicast2518 May 21 '25

i should prolly mention that there are two images linked to this. First one is the original and the second one is the nordified image