Skip to content

Commit c070a0f

Browse files
16
1 parent 110ec2a commit c070a0f

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

16.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from PIL import Image
2+
3+
4+
def straighten(source):
5+
target = source.copy()
6+
for y in range(source.size[1]):
7+
line = [source.getpixel((x, y)) for x in range(source.size[0])]
8+
pink = line.index(195)
9+
line = line[pink:] + line[:pink]
10+
for x, pixel in enumerate(line):
11+
target.putpixel((x, y), pixel)
12+
return target
13+
14+
15+
out = straighten(Image.open("mozart/mozart.gif"))
16+
out.save("mozart/out.gif")

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# pythonchallenge
22
Solve Problems in http://www.pythonchallenge.com
33

4+
#### 16
5+
result: http://www.pythonchallenge.com/pc/return/romance.html
6+
```python
7+
from PIL import Image
8+
```
9+
- this gif is a P mode picture which use one 8 bit number to declare a color
10+
- straight is a way to handle these pixels
11+
412
#### 15
513
result: http://www.pythonchallenge.com/pc/return/mozart.html
614

mozart/mozart.gif

248 KB
Loading

mozart/out.gif

339 KB
Loading

0 commit comments

Comments
 (0)