回答編集履歴

1

PILで変更後の保存方法を追加

2017/04/05 06:07

投稿

sharow
sharow

スコア1149

test CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
 
5
5
  ```python3
6
+
7
+
6
8
 
7
9
  import urllib.request
8
10
 
@@ -22,8 +24,22 @@
22
24
 
23
25
  pil_img = Image.open(img_bin) # PILで開く
24
26
 
27
+ # PILでごにょごにょする
25
28
 
26
29
 
30
+
31
+ # PNGでエンコード
32
+
33
+ modified_bin = io.BytesIO()
34
+
35
+ pil_img.save(modified_bin, format='PNG')
36
+
37
+
38
+
39
+ # ブログにアップロードしたり
40
+
27
- # バイナリ(bytes)を得る場合は img_bin.getvalue() とする
41
+ # hogehoge.send(hoge_url, body=modified_bin.getvalue())
42
+
43
+
28
44
 
29
45
  ```