Kasper Bielecki

From the class Code as a Liberal Art · Spring 2022

Kitsch & Chaos

Kitsch & Chaos artwork #1 Kitsch & Chaos artwork #2 Kitsch & Chaos artwork #3 Kitsch & Chaos artwork #4 Kitsch & Chaos artwork #5 Kitsch & Chaos artwork #6 Kitsch & Chaos artwork #7 Kitsch & Chaos artwork #8 Kitsch & Chaos artwork #9 Kitsch & Chaos artwork #10 Kitsch & Chaos artwork #11 Kitsch & Chaos artwork #12 Kitsch & Chaos artwork #13 Kitsch & Chaos artwork #14 Kitsch & Chaos artwork #15 Kitsch & Chaos artwork #16 Kitsch & Chaos artwork #17 Kitsch & Chaos artwork #18 Kitsch & Chaos artwork #19 Kitsch & Chaos artwork #20 Kitsch & Chaos artwork #21 Kitsch & Chaos artwork #22 Kitsch & Chaos artwork #23 Kitsch & Chaos artwork #24 Kitsch & Chaos artwork #25 Kitsch & Chaos artwork #26 Kitsch & Chaos artwork #27 Kitsch & Chaos artwork #28 Kitsch & Chaos artwork #29 Kitsch & Chaos artwork #30 Kitsch & Chaos artwork #31 Kitsch & Chaos artwork #32 Kitsch & Chaos artwork #33 Kitsch & Chaos artwork #34

KitschAndChaos.py

import sys
from os import listdir, path
import random
from PIL import Image

directory_name = "kitsch&chaosimagedirectory"
i = 1

while True:
    print('___________________________________________________________________________________')
    print('Enter the name of the Kitsch & Choas artwork we are about to create together!:')
    title = input()
    print('*')
    print('Enter your name:')
    name = input()

    files = listdir(directory_name)
    files.remove(".DS_Store")

    file1 = random.choice(files)
    img1 = Image.open( path.join(directory_name,file1) )

    file2 = random.choice(files)
    img2 = Image.open( path.join(directory_name,file2) )

    file3 = random.choice(files)
    img3 = Image.open( path.join(directory_name,file3) )

    file4 = random.choice(files)
    img4 = Image.open( path.join(directory_name,file4) )

    file5 = random.choice(files)
    img5 = Image.open( path.join(directory_name,file5) )

    file6 = random.choice(files)
    img6 = Image.open( path.join(directory_name,file6) )

    file7 = random.choice(files)
    img7 = Image.open( path.join(directory_name,file7) )

    file8 = random.choice(files)
    img8 = Image.open( path.join(directory_name,file8) )



    img1.thumbnail( (400,400) )
    img2.thumbnail( (400,400) )
    img3.thumbnail( (400,400) )
    img4.thumbnail( (400,400) )
    img5.thumbnail( (400,400) )
    img6.thumbnail( (400,400) )
    img7.thumbnail( (400,400) )
    img8.thumbnail( (400,400) )

    new_image = Image.new( "RGBA", (800,800), "white" )

    new_image.paste(img1, (0,0) )

    img2_hsv = img2.convert(mode="HSV")

    (width,height) = img2_hsv.size
    for x in range(width):
        for y in range(height):
            pixel = img2_hsv.getpixel((x,y))
            if pixel[2] > 128:
                img2_hsv.putpixel( (x,y), (0,0,255) )

    img2_alpha = img2_hsv.convert("RGBA")

    (width,height) = img2_alpha.size
    for x in range(width):
        for y in range(height):
            (red,green,blue,alpha) = img2_alpha.getpixel((x,y))
            if red == 255 and blue == 255 and green == 255:
                img2_alpha.putpixel( (x,y), (0,0,0,0) )

    new_image.alpha_composite(img2_alpha, (0,0) )

    new_image.paste(img3, (400,0) )

    img4_hsv = img4.convert(mode="HSV")

    (width,height) = img4_hsv.size
    for x in range(width):
        for y in range(height):
            pixel = img4_hsv.getpixel((x,y))
            if pixel[2] > 128:
                img4_hsv.putpixel( (x,y), (0,0,255) )

    img4_alpha = img4_hsv.convert("RGBA")

    (width,height) = img4_alpha.size
    for x in range(width):
        for y in range(height):
            (red,green,blue,alpha) = img4_alpha.getpixel((x,y))
            if red == 255 and blue == 255 and green == 255:
                img4_alpha.putpixel( (x,y), (0,0,0,0) )

    new_image.alpha_composite(img4_alpha, (400,0) )

    new_image.paste(img5, (0,400) )

    img6_hsv = img6.convert(mode="HSV")

    (width,height) = img6_hsv.size
    for x in range(width):
        for y in range(height):
            pixel = img6_hsv.getpixel((x,y))
            if pixel[2] > 128:
                img6_hsv.putpixel( (x,y), (0,0,255) )

    img6_alpha = img6_hsv.convert("RGBA")

    (width,height) = img6_alpha.size
    for x in range(width):
        for y in range(height):
            (red,green,blue,alpha) = img6_alpha.getpixel((x,y))
            if red == 255 and blue == 255 and green == 255:
                img6_alpha.putpixel( (x,y), (0,0,0,0) )

    new_image.alpha_composite(img6_alpha, (0,400) )

    new_image.paste(img7, (400,400) )

    img8_hsv = img8.convert(mode="HSV")

    (width,height) = img8_hsv.size
    for x in range(width):
        for y in range(height):
            pixel = img8_hsv.getpixel((x,y))
            if pixel[2] > 128:
                img8_hsv.putpixel( (x,y), (0,0,255) )

    img8_alpha = img8_hsv.convert("RGBA")

    (width,height) = img8_alpha.size
    for x in range(width):
        for y in range(height):
            (red,green,blue,alpha) = img8_alpha.getpixel((x,y))
            if red == 255 and blue == 255:
                img8_alpha.putpixel( (x,y), (0,0,0,0) )

    new_image.alpha_composite(img8_alpha, (400,400) )

    new_image.convert("RGBA").save(title+" by "+name+" and Algoritm - K&C Artwork #"+str(i)+".png")
    i = i+1
    print('*')
    print('All Done! Look to the left to see our new creation :)... NEXT!!!!')
    print('___________________________________________________________________________________')
    print('*')
    print('*')
    print('*')