blob: 58ed53d738c734bfc5048dc4d227f5c156246882 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from six.moves import cStringIO as StringIO
from PIL import Image
def response(context, flow):
if flow.response.headers.get("content-type", "").startswith("image"):
try:
s = StringIO(flow.response.content)
img = Image.open(s).rotate(180)
s2 = StringIO()
img.save(s2, "png")
flow.response.content = s2.getvalue()
flow.response.headers["content-type"] = "image/png"
except: # Unknown image types etc.
pass
|