Closed GoogleCodeExporter closed 8 years ago
I suspect the ppm file is irrelevant. Any PPM (or PGM) will result in broken
output on Windows.
The problem is probably that on Windows stdout is opened in text mode so the
binary file that PyPNG writes to it gets corrupted. The PNG format
deliberately has a newline in it's header so that exactly this problem can be
detected early when reading a broken PNG.
On windows, we need to convert sys.stdout from text to binary mode. This is
not possible portably, but there may be some windows-specific hack. I do not
have access to a Windows machine. :)
(it's probably opened in text mode on OS X and Linux too but it makes no
difference)
Original comment by drj...@googlemail.com
on 20 Apr 2012 at 10:00
Here's a decent hack for this:
http://stackoverflow.com/questions/2374427/python-2-x-write-binary-output-to-std
out
I tested it on a Windows machine with the original example and it works fine
under Python 2.7. Attached is a modified version of png.py with this fix and
its diff against the current version of the repository.
Original comment by nathan.m...@gmail.com
on 20 Apr 2012 at 4:48
Attachments:
Applied as revision 237. Thanks!
Original comment by drj...@googlemail.com
on 25 Apr 2012 at 12:05
Great!
Original comment by nathan.m...@gmail.com
on 25 Apr 2012 at 12:12
Original comment by drj...@googlemail.com
on 1 Dec 2012 at 11:33
Original issue reported on code.google.com by
nathan.m...@gmail.com
on 2 Jul 2011 at 2:18Attachments: