Skip to content

Commit 2d98fca

Browse files
committed
Files Uploaded
first init
1 parent adaca11 commit 2d98fca

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

combine_image.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from PIL import Image
2+
3+
file_input = input("Source code with extension (for default press enter): ")
4+
5+
if file_input == "":
6+
file_input = "output.txt"
7+
8+
text_file = open(file_input, "r")
9+
10+
lines = str(text_file.readlines())
11+
12+
image = lines.split("|")
13+
14+
width = int(image[-3].split("-")[0]) + 1
15+
height = int(image[-3].split("-")[1]) + 1
16+
17+
coords = 1
18+
rgbvalue = 2
19+
20+
img = Image.new('RGB', (width, height))
21+
22+
while True:
23+
rgbvalue += 2
24+
coords += 2
25+
26+
if int(image[coords].split("-")[1]) == height - 1 and int(image[coords].split("-")[0]) == width - 1:
27+
break
28+
29+
else:
30+
cord = image[coords]
31+
32+
print (int((width * (int(cord.split("-")[1]))) / (width * height) * 100), "% - Please Wait.")
33+
34+
rgbimg = image[rgbvalue][1:-1].split(",")
35+
36+
img.putpixel((int(cord.split("-")[0]), int(cord.split("-")[1])), (int(rgbimg[0]), int(rgbimg[1]), int(rgbimg[2])))
37+
38+
img.save('export.png')

example.jpg

514 KB
Loading

parse_image.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from PIL import Image
2+
3+
im = Image.open(input("File Name (with extension): "))
4+
width, height = im.size
5+
px = im.load()
6+
7+
satir = 1
8+
cell = 0
9+
10+
i = 0
11+
12+
f=open("output.txt", 'w')
13+
f.write("START|")
14+
15+
while True:
16+
cell += 1
17+
if cell == width:
18+
cell = 0
19+
satir += 1
20+
else:
21+
coordinate = x, y = cell, satir
22+
f.write(str(cell) + '-' + str(satir) + '|' + str(im.getpixel(coordinate)) + '|')
23+
print (int((width * (satir)) / (width * height) * 100), "% - Please Wait.")
24+
i+=1
25+
26+
if satir == height and cell == width - 1:
27+
f.write(str(cell) + '-' + str(satir) + '|' + str(im.getpixel(coordinate)) + '|')
28+
f.write("FINISH")
29+
break

0 commit comments

Comments
 (0)