Skip to content

Commit 264e189

Browse files
try 27
1 parent db5a076 commit 264e189

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

27.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import download_file
2-
import read_bin_file
32

43
from PIL import Image
4+
from PIL import ImageSequence
55

66

77
def main():
8-
url = "http://www.pythonchallenge.com/pc/hex/zigzag.jpg"
9-
file_path = "zigzag/zigzag.jpg"
8+
file_name = "zigzag.gif"
9+
url = "http://www.pythonchallenge.com/pc/hex/{}".format(file_name)
10+
file_path = "zigzag/{}".format(file_name)
1011
user = "butter"
1112
password = "fly"
1213
# first_step(url, file_path, user, password)
13-
# second_step(file_path)
14-
third_step(file_path)
14+
second_step(file_path)
1515

1616

1717
def first_step(url, file_path, user, password):
1818
download_file.download_with_auth(url, file_path, user, password)
1919

2020

2121
def second_step(file_path):
22-
ary = read_bin_file.read_bin_file(file_path)
23-
print(ary)
24-
25-
26-
def third_step(file_path):
2722
im = Image.open(file_path)
28-
print(im)
29-
width, height = im.size
23+
for frame in ImageSequence.Iterator(im):
24+
width, height = frame.size
25+
for x in range(width):
26+
for y in range(height):
27+
pixel = frame.getpixel((x, y))
28+
print(pixel, end=" ")
29+
print(" ")
3030

3131

3232
if __name__ == "__main__":

zigzag/zigzag.gif

96.4 KB
Loading

0 commit comments

Comments
 (0)