This commit is contained in:
Denis Lehmann 2021-07-14 17:08:24 +02:00
parent f79263965c
commit 42852bc047
2 changed files with 25 additions and 445 deletions

View file

@ -1,10 +1,12 @@
#!/usr/bin/env python
from PIL import Image, ImageDraw, ImageOps
from colour import Color
import argparse
import os.path
import random
import sys
from colour import Color
from PIL import Image, ImageDraw, ImageOps
def print_logo():
logo = """
@ -21,8 +23,11 @@ def print_logo():
"""
print(logo)
def get_base_color(color_string=None):
global sat_min, sat_max, lum_min, lum_max
# If no color string is given, create a random color
if not color_string:
hue = random.uniform(0, 1)
@ -41,8 +46,11 @@ def get_base_color(color_string=None):
return base_color
def create_colors(base_color):
global max_hue, sat_min, sat_max, lum_min, lum_max
colors = []
max_sat_diff = 0.1
@ -66,12 +74,15 @@ def create_colors(base_color):
return tuple(colors)
# c1 - top left
# c2 - top right
# c3 - bottom right
# c4 - bottom left
def create_base_image(c1, c2, c3, c4):
global width, height
# Lambda for adding four colors
add = lambda c1, c2, c3, c4: (
c1[0] + c2[0] + c3[0] + c4[0],
@ -106,8 +117,11 @@ def create_base_image(c1, c2, c3, c4):
return image
def add_lines(image, color):
global width, height
line_image = Image.new("RGBA", (width, height), (0, 0, 0, 0))
draw = ImageDraw.Draw(line_image)
@ -139,15 +153,21 @@ def add_lines(image, color):
return image
def add_pixelation(image, x, y):
global width, height
image = image.resize((x, y))
image = image.resize((width, height), Image.BOX)
return image
def add_emblem(image, filepath):
global width, height
# Load image
try:
emblem_image = Image.open(filepath)
@ -169,6 +189,7 @@ def add_emblem(image, filepath):
return image
def save_image(filepath, image):
save = True
@ -200,7 +221,8 @@ def save_image(filepath, image):
"Please enter new path where the wallpaper shall be saved: "
)
def main():
if __name__ == "__main__":
global width, height, max_hue, sat_min, sat_max, lum_min, lum_max
@ -353,7 +375,3 @@ def main():
if output:
save_image(output, image)
if __name__ == "__main__":
main()