Skip to content

Instantly share code, notes, and snippets.

@CutestNekoAqua
Created April 12, 2022 19:03
Show Gist options
  • Save CutestNekoAqua/7f06359363708908fc4b943be1894764 to your computer and use it in GitHub Desktop.
Save CutestNekoAqua/7f06359363708908fc4b943be1894764 to your computer and use it in GitHub Desktop.
#Importierung der Bibliotheken
from PIL import Image
import numpy as np
import random
#Erstellung des Images
img = Image.new('RGB', (100, 100))
#Liste zur Speicherung der Pixel
array = np.empty((100*100,3))
#Eröffnung der Koordinaten
g = 0
#Eröffnung der Farbe
k = 0
#Durchlauf jedes einzelnen Pixels für Position und Farbe
for x in array:
for y in x:
array[g][k] = random.randint(0, 265)
k += 1
g +=1
k = 0
#Umwandlung des Ergebnisses in Tuple
result = [tuple(int(y) for y in e) for e in array]
#Speicherung der Daten im Bild
img.putdata(result)
#Bild als Datei abgespeichert
img.save('image.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment