Skip to content

Instantly share code, notes, and snippets.

@pat36
Last active September 3, 2016 18:34
Show Gist options
  • Save pat36/1376ee4438db155ac7b0f084e644ad7f to your computer and use it in GitHub Desktop.
Save pat36/1376ee4438db155ac7b0f084e644ad7f to your computer and use it in GitHub Desktop.
działający generator obrazów
import numpy as np
from random import randint
from PIL import Image as img
height = int(input("Podaj wysokosc obrazu: "))
width = int(input("Podaj szerokosc obrazu: "))
image = np.zeros(shape=(width, height), dtype="S6")
for i in range(0, height):
for j in range(0, width):
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
rgb = r * 65536 + g * 256 + b
image[i][j] = hex(rgb)[2:]
tmpImg = img.fromarray(image, "RGB")
tmpImg.save("obrazek.jpg")
tmpImg.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment