Skip to content

Commit d60e9ff

Browse files
committed
fix screenshot: save after RGB and size processing
1 parent 183a3f0 commit d60e9ff

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pythonhere/magic_here/shortcuts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def screenshot(ctx, width, output):
5959
ctx.obj.runcode()
6060
data = b64decode(err.getvalue())
6161

62-
if output:
63-
output.write(data)
64-
output.close()
65-
6662
img = PILImage.open(BytesIO(data)).convert("RGB")
6763
if width:
6864
height = int(width * img.size[1] // img.size[0])
6965
img = img.resize((width, height), PILImage.ANTIALIAS)
7066

67+
if output:
68+
img.save(output)
69+
output.close()
70+
7171
display(img)

0 commit comments

Comments
 (0)