-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmogPixel.py
38 lines (24 loc) · 951 Bytes
/
mogPixel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PIL import Image
class PixelArt:
def pixel(self, pixelSize, image):
imageWeidth, imageHeight = image.size
if pixelSize == "small":
SIZE =10
elif pixelSize == "medium":
SIZE =20
elif pixelSize == "large":
SIZE=25
else:
return f'MogFaill'
for y in range(0,imageWeidth,SIZE):
for x in range(0,imageHeight,SIZE):
pixel = image.getpixel((x,y))
for a in range(y,min(y+SIZE,imageWeidth)):
for b in range(x,min(x+SIZE,imageHeight)):
image.putpixel((b,a),pixel)
output_filename= f'output{pixelSize.capitalize()}.png'
image.save(output_filename)
return f'Image {output_filename} crée avec succès'
img = Image.open(r'C:\Users\y_mc\PycharmProjects\Mogwai_Wallet\Mogwai .PNG')
MogPix = PixelArt()
output =MogPix.pixel("large",img)