Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e0a2e3

Browse files
try 27
1 parent264e189 commit1e0a2e3

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

‎27.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
importdownload_file
22

33
fromPILimportImage
4-
fromPILimportImageSequence
54

65

76
defmain():
@@ -11,7 +10,9 @@ def main():
1110
user="butter"
1211
password="fly"
1312
# first_step(url, file_path, user, password)
14-
second_step(file_path)
13+
raw,result=second_step(file_path)
14+
raw_ary,result_ary=third_step(raw,result)
15+
fourth_step(raw_ary,result_ary)
1516

1617

1718
deffirst_step(url,file_path,user,password):
@@ -20,13 +21,28 @@ def first_step(url, file_path, user, password):
2021

2122
defsecond_step(file_path):
2223
im=Image.open(file_path)
23-
forframeinImageSequence.Iterator(im):
24-
width,height=frame.size
25-
forxinrange(width):
26-
foryinrange(height):
27-
pixel=frame.getpixel((x,y))
28-
print(pixel,end=" ")
29-
print(" ")
24+
raw=im.tobytes()
25+
palette=im.getpalette()[::3]
26+
index="".join([chr(i)foriinrange(len(palette))])
27+
value="".join([chr(palette[i])foriinrange(len(palette))])
28+
table=str.maketrans(index,value)
29+
result=raw.decode("latin1").translate(table).encode("latin1")
30+
returnraw,result
31+
32+
33+
defthird_step(raw,result):
34+
raw_ary= []
35+
result_ary= []
36+
assertlen(raw)==len(result)
37+
l=len(raw)
38+
foriinrange(l):
39+
raw_ary.append(raw[i])
40+
result_ary.append(result[i])
41+
returnraw_ary,result_ary
42+
43+
44+
deffourth_step(raw_ary,result_ary):
45+
pass
3046

3147

3248
if__name__=="__main__":

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp