On Mon, Jul 16, 2012 at 1:41 PM, PKHG <[email protected]> wrote:
> This
>>>> struct.pack("8B", 137, 80, 78, 71, 13, 10, 26, 10)
> b'\x89PNG\r\n\x1a\n'
> gives an error
> from line  (258 of my pypng.py)       outfile.write(struct.pack("8B", 137,
> 80, 78, 71, 13, 10, 26, 10))
>
> I assume that write needs an utf-8 string but the 137 from the pack is not
> convertable ... to utf-8
>
> So what should it be?

It should not be converted to utf-8. PNG is a binary format and
therefore write() needs bytes (as returned by struct.pack).
Do you have a short example that produces the error? Saving a image
with the PNGImageEncoder works fine for me with Python 3.2.

I guess you are incorrectly opening the file in text mode, either by
specifying an encoding like utf-8, or you forgot to open the file in
binary mode.


Regarding the new pypng version, as far as I know it doesn't work as a
drop in replacement, because the version embedded in pyglet has some
pyglet specific changes. As pyglets version is quite old, I guess that
rebasing those changes would be quite some work.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to