-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.py
More file actions
35 lines (28 loc) · 718 Bytes
/
convert.py
File metadata and controls
35 lines (28 loc) · 718 Bytes
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
from PIL import Image
from PIL import ImageColor
name = input('Enter File Name')
#name = 'graphic'
img = Image.open(name)
f = open(name + '.txt','w')
print(str(img.height))
print(str(img.width))
f.write(str(img.height))
f.write('\n')
f.write(str(img.width))
f.write('\n')
height = img.height
width = img.width
#pix = img.load()
rgb = img.convert('RGB')
img.close()
for r in range(0,height,1):
for c in range(0,width,1):
#print(rgb.getpixel((c,r)))
R, G, B = rgb.getpixel((c, r))
#print(str(R), str(G), str(B), ' ', end = '')
line = str(R) + ' ' + str(G) + ' ' + str(B) + ' '
#print(str(line), end = ' ')
f.write(line)
#print()
f.write('\n')
f.close()