FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/pythonchallenge/16.py at master · bjd1111/python · GitHub
bjd1111
python
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
pythonchallenge
/
16.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
106 lines (76 loc) · 2.02 KB
Breadcrumbs
python
/
pythonchallenge
/
16.py
Copy path
File metadata and controls
106 lines (76 loc) · 2.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""
import Image
image = Image.open('mozart.gif')
#for i in xrange(429,434):
# print i,0,'color', image.getpixel((i,0))
def pink():
pink_cord = []
pink = []
i,j = image.size
n = 0
for y in xrange(j):
for x in xrange(i):
if image.getpixel((x,y)) == 195:
pink_cord.append((x,y))
for i in xrange(0,len(pink_cord),5):
b = pink_cord[i:i+5]
pink.append(b)
return pink
def crop_cord():
cord = []
a = 0
b = 0
for item in pink():
i,j = item[-1]
#print i,j
c = []
if j-b ==0:
for x in xrange(a,i):
c.append((x,0))
elif j-b ==1:
for x in xrange(a,image.size[0]):
c.append((x,b))
for x in xrange(0,i):
c.append((x,j))
cord.append(c)
a = item[-1][0]
b = item[-1][1]
return cord
def reverse(cord):
a = []
c = cord
for i in xrange(len(cord)):
a.append(c.pop())
return a
img = Image.new('P',(2000,1000))
def paste(img):
col = 0
for i in crop_cord():
#i = reverse(n)
val = []
row = 0
for item in i:
val.append(image.getpixel(item))
#print val
#print val
for i in xrange(len(val)):
#print i,col
img.putpixel((i,col),val[i])
row +=1
col+=1
#print 'EEEEEEEEEEEEEEEEEEENNNNNNNNNNNNNNNNNNNNDDDDDDDDDDD'
img.show()
paste(img)
"""
import
Image
def
straighten
(
source
):
target
=
source
.
copy
()
for
y
in
range
(
source
.
size
[
1
]):
line
=
[
source
.
getpixel
((
x
,
y
))
for
x
in
range
(
source
.
size
[
0
])]
pink
=
line
.
index
(
195
)
line
=
line
[
pink
:]
+
line
[:
pink
]
for
x
,
pixel
in
enumerate
(
line
):
target
.
putpixel
((
x
,
y
),
pixel
)
return
target
out
=
straighten
(
Image
.
open
(
"mozart.gif"
))
out
.
show
()
Back
|
FazBrowse Home
|
New Git URL