-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't save PNG to sys.stdout #5436
Comments
Hi. You're free to say that Pillow should be able to work with your code, and that you'd like it to be fixed in the next Pillow release - but if you'd like an immediate solution, I'd suggest changing import sys
from PIL import Image, ImageDraw
# list of dots, in the following format: [x, y, x, y, x, y,...]
first = (146, 399, 163, 403, 170, 393, 169, 391, 166, 386, 170, 381, 170) #.... long tuple
with Image.open("draw image.jpg") as img:
draw = ImageDraw.Draw(img)
for i in range(len(first)//2 - 1):
draw.line(first[2*i : 2*i + 4])
# write to stdout
img.save(sys.stdout.buffer, "PNG") This makes a difference because while >>> import sys
>>> sys.stdout.mode
'w'
>>> sys.stdout.buffer.mode
'wb' |
I've found that we have an example in our documentation that is similar to this, so yes, this is a bug. I've created PR #5437 to resolve it. The earliest that could become a part of a Pillow release is July 1. |
Yes, I copied the code from the documentation, and that's why I was surprised that it's not working. I assumed this is problem with my system... |
What did you do?
Just tried to run simple code (ImageDraw)
What did you expect to happen?
What actually happened?
Exception looks very basic:
What are your OS, Python and Pillow versions?
Sorry if I didn't understand the concept... This is my first issue ever...
The text was updated successfully, but these errors were encountered: