mitmproxy/examples/upsidedownternet.py

11 lines
334 B
Python
Raw Normal View History

2014-01-04 02:15:08 +00:00
import cStringIO
from PIL import Image
def response(context, flow):
if flow.response.headers["content-type"] == ["image/png"]:
s = cStringIO.StringIO(flow.response.content)
img = Image.open(s).rotate(180)
s2 = cStringIO.StringIO()
img.save(s2, "png")
flow.response.content = s2.getvalue()