when i try to upload images i get following Error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0:
invalid start byte
. Everything works fine until i call Image.open(f), from PIL import Image.
x = web.input(bilder={})
b = Bilder()
b.set_image(x.bilder.file)
b.save()
...
class Bilder(Document):
...
def set_image(self, f):
_i = Image.open(f, 'wb')
...
Hi,
when i try to upload images i get following Error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte
. Everything works fine until i call Image.open(f), from PIL import Image.
x = web.input(bilder={})
b = Bilder()
b.set_image(x.bilder.file)
b.save()
...
class Bilder(Document):
...
def set_image(self, f):
_i = Image.open(f, 'wb')
...
--
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
x = web.input(bilder={})
b.set_image(x.bilder.file)
----
f = x.bilder.file
----
Am 09.02.2012 16:23, schrieb Primoz Anzur:
> What is 'f'? Is it image data or the filename?
>
> On Thu, Feb 9, 2012 at 12:38 PM, Patrick Erdmann <pat...@perdmann.de
> <mailto:pat...@perdmann.de>> wrote:
>
> Hi,
>
> when i try to upload images i get following Error:
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position
> 0: invalid start byte
>
> . Everything works fine until i call Image.open(f), from PIL import
> Image.
>
> x = web.input(bilder={})
> b = Bilder()
> b.set_image(x.bilder.file)
> b.save()
>
> ...
> class Bilder(Document):
> ...
> def set_image(self, f):
> _i = Image.open(f, 'wb')
> ...
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com.
> To unsubscribe from this group, send email to
> webpy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
--
Mit freundlichen Gr��en
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de><mailto:we...@googlegroups.com>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.comwebpy+unsubscribe@__googlegroups.com
To unsubscribe from this group, send email to
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
http://groups.google.com/__group/webpy?hl=en
For more options, visit this group at
<http://groups.google.com/group/webpy?hl=en>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+unsubscribe@googlegroups.com.
I dont want to use tmp_file or write it to disk, because i use GridFS to
store Files.
>
> On Sat, Feb 11, 2012 at 8:47 AM, Primoz Anzur <stormc...@gmail.com
> <mailto:stormc...@gmail.com>> wrote:
>
> This is not how you use PIL
> http://www.pythonware.com/library/pil/handbook/image.htm
>
> Image.open(infile) => image
> Image.open(infile, mode) => image
>
>
> On Fri, Feb 10, 2012 at 7:58 PM, Patrick Erdmann
> <pat...@perdmann.de <mailto:pat...@perdmann.de>> wrote:
>
> f is image data, see here:
>
> x = web.input(bilder={})
> b.set_image(x.bilder.file)
> ----
> f = x.bilder.file
> ----
>
>
> Am 09.02.2012 16:23, schrieb Primoz Anzur:
>
> What is 'f'? Is it image data or the filename?
>
> On Thu, Feb 9, 2012 at 12:38 PM, Patrick Erdmann
> <pat...@perdmann.de <mailto:pat...@perdmann.de>
> <mailto:pat...@perdmann.de <mailto:pat...@perdmann.de>>>
> wrote:
>
> Hi,
>
> when i try to upload images i get following Error:
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xff
> in position
> 0: invalid start byte
>
> . Everything works fine until i call Image.open(f), from
> PIL import
> Image.
>
> x = web.input(bilder={})
> b = Bilder()
> b.set_image(x.bilder.file)
> b.save()
>
> ...
> class Bilder(Document):
> ...
> def set_image(self, f):
> _i = Image.open(f, 'wb')
> ...
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de
> <mailto:pat...@perdmann.de> <mailto:pat...@perdmann.de
> <mailto:pat...@perdmann.de>>
>
>
> --
> You received this message because you are subscribed to
> the Google
> Groups "web.py" group.
> To post to this group, send email to
> we...@googlegroups.com <mailto:we...@googlegroups.com>
> <mailto:we...@googlegroups.com
> <mailto:we...@googlegroups.com>__>.
>
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegrou__ps.com
> <http://googlegroups.com>
> <mailto:webpy%2Bunsubscribe@__googlegroups.com
> <mailto:webpy%252Buns...@googlegroups.com>>.
>
> For more options, visit this group at
> http://groups.google.com/____group/webpy?hl=en
> <http://groups.google.com/__group/webpy?hl=en>
> <http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>>.
>
>
>
> --
> You received this message because you are subscribed to the
> Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
>
> --
> You received this message because you are subscribed to the
> Google Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com.
> To unsubscribe from this group, send email to
> webpy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
--
x = web.input(bilder={})
b.set_image(x.bilder.file)
----
f = x.bilder.file
----
And the failure happens in
/web/net.py
Am 09.02.2012 16:23, schrieb Primoz Anzur:
> What is 'f'? Is it image data or the filename?
>
> On Thu, Feb 9, 2012 at 12:38 PM, Patrick Erdmann <pat...@perdmann.de
> <mailto:pat...@perdmann.de>> wrote:
>
> Hi,
>
> when i try to upload images i get following Error:
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position
> 0: invalid start byte
>
> . Everything works fine until i call Image.open(f), from PIL import
> Image.
>
> x = web.input(bilder={})
> b = Bilder()
> b.set_image(x.bilder.file)
> b.save()
>
> ...
> class Bilder(Document):
> ...
> def set_image(self, f):
> _i = Image.open(f, 'wb')
> ...
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com.
> To unsubscribe from this group, send email to
> webpy+un...@googlegroups.com.
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de><mailto:we...@googlegroups.com>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.comwebpy+unsubscribe@__googlegroups.com
To unsubscribe from this group, send email to
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
http://groups.google.com/__group/webpy?hl=en
For more options, visit this group at
<http://groups.google.com/group/webpy?hl=en>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+unsubscribe@googlegroups.com.
<mailto:pat...@perdmann.de> <mailto:pat...@perdmann.de<mailto:we...@googlegroups.com
<mailto:pat...@perdmann.de>>
--
You received this message because you are subscribed to
the Google
Groups "web.py" group.
To post to this group, send email to
we...@googlegroups.com <mailto:we...@googlegroups.com>
<mailto:we...@googlegroups.com>__>.webpy+unsubscribe@__googlegrou__ps.com
To unsubscribe from this group, send email to
<http://googlegroups.com>
<mailto:webpy%2Bunsubscribe@__googlegroups.com
<mailto:webpy%252Bunsubscribe@googlegroups.com>>.
http://groups.google.com/____group/webpy?hl=en
For more options, visit this group at
<http://groups.google.com/__group/webpy?hl=en>
<http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>>.
--
You received this message because you are subscribed to the
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com
<mailto:we...@googlegroups.com>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegroups.com
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>.
--
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
--
You received this message because you are subscribed to the
Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com
<mailto:we...@googlegroups.com>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegroups.com
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+unsubscribe@googlegroups.com.
Thanks for your help!
Am 14.02.2012 12:17, schrieb Primoz Anzur:
> Wait a tick.
> Why do you actually need PIL? Why not just directly store into the GridFS?
> If you need image manipulation, then you have no choice but to use PIL's
> handling.
> You could do something like this:
>
> img = Image.fromstring(f.read())
> <do things that needed to be done>
> write_image_into_database_thingy(img.tostring("jpeg")) #I think, that
> this should be enough.
>
> That's about it.
>
> The upload part will give you tmp_file, whether you like it or not,
> anyways. That's how uploads work.
>
> On Mon, Feb 13, 2012 at 3:27 PM, Patrick Erdmann <pat...@perdmann.de
> <mailto:pat...@perdmann.de>> wrote:
>
> Am 11.02.2012 08:50, schrieb Primoz Anzur:
>
> Maybe you've wanted Image.frombuffer() or Image.fromstring()?
>
> I tried, but to "convert" a File Object to an Image - File Object i
> read to use Image.open(file).
>
> I dont want to use tmp_file or write it to disk, because i use
> GridFS to store Files.
>
>
> On Sat, Feb 11, 2012 at 8:47 AM, Primoz Anzur
> <stormc...@gmail.com <mailto:stormc...@gmail.com>
> <mailto:stormc...@gmail.com
> <mailto:stormc...@gmail.com>__>> wrote:
>
> This is not how you use PIL
> http://www.pythonware.com/__library/pil/handbook/image.htm
> <http://www.pythonware.com/library/pil/handbook/image.htm>
>
> Image.open(infile) => image
> Image.open(infile, mode) => image
>
>
> On Fri, Feb 10, 2012 at 7:58 PM, Patrick Erdmann
> <pat...@perdmann.de <mailto:pat...@perdmann.de>
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de
> <mailto:pat...@perdmann.de>
> <mailto:pat...@perdmann.de <mailto:pat...@perdmann.de>>
> <mailto:pat...@perdmann.de <mailto:pat...@perdmann.de>
>
> <mailto:pat...@perdmann.de <mailto:pat...@perdmann.de>>>
>
>
> --
> You received this message because you are
> subscribed to
> the Google
> Groups "web.py" group.
> To post to this group, send email to
> we...@googlegroups.com <mailto:we...@googlegroups.com>
> <mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>__>
> <mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>
> <mailto:we...@googlegroups.com
> <mailto:we...@googlegroups.com>__>__>.
>
>
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegrou____ps.com
> <http://googlegrou__ps.com>
> <http://googlegroups.com>
> <mailto:webpy%2Bunsubscribe@
> <mailto:webpy%252Bunsubscribe@>____googlegroups.com
> <http://googlegroups.com>
> <mailto:webpy%252Bunsubscribe@__googlegroups.com
> <mailto:webpy%25252Bun...@googlegroups.com>>>.
>
>
> For more options, visit this group at
> http://groups.google.com/______group/webpy?hl=en
> <http://groups.google.com/____group/webpy?hl=en>
> <http://groups.google.com/____group/webpy?hl=en
> <http://groups.google.com/__group/webpy?hl=en>>
>
> <http://groups.google.com/____group/webpy?hl=en
> <http://groups.google.com/__group/webpy?hl=en>
> <http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>>>.
>
>
>
> --
> You received this message because you are subscribed
> to the
> Google
> Groups "web.py" group.
> To post to this group, send email to
> we...@googlegroups.com <mailto:we...@googlegroups.com>
> <mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>__>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegrou__ps.com
> <http://googlegroups.com>
> <mailto:webpy%2Bunsubscribe@__googlegroups.com
> <mailto:webpy%252Buns...@googlegroups.com>>.
> For more options, visit this group at
> http://groups.google.com/____group/webpy?hl=en
> <http://groups.google.com/__group/webpy?hl=en>
> <http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>>.
>
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de
> <mailto:pat...@perdmann.de> <mailto:pat...@perdmann.de
> <mailto:pat...@perdmann.de>>
>
> --
> You received this message because you are subscribed to the
> Google Groups "web.py" group.
> To post to this group, send email to
> we...@googlegroups.com <mailto:we...@googlegroups.com>
> <mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>__>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegrou__ps.com
> <http://googlegroups.com>
> <mailto:webpy%2Bunsubscribe@__googlegroups.com
> <mailto:webpy%252Buns...@googlegroups.com>>.
> For more options, visit this group at
> http://groups.google.com/____group/webpy?hl=en
> <http://groups.google.com/__group/webpy?hl=en>
> <http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
>
> --
> Mit freundlichen Gr��en
>
> Patrick Erdmann
>
> XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com
> <mailto:we...@googlegroups.com>.
> To unsubscribe from this group, send email to
> webpy+unsubscribe@__googlegroups.com
> <mailto:webpy%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/webpy?hl=en
> <http://groups.google.com/group/webpy?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "web.py" group.
> To post to this group, send email to we...@googlegroups.com.
> To unsubscribe from this group, send email to
> webpy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
--
Mit freundlichen Grüßen
<mailto:webpy%25252Bunsubscribe@googlegroups.com>>>.
http://groups.google.com/______group/webpy?hl=en
For more options, visit this group at
<http://groups.google.com/____group/webpy?hl=en>
<http://groups.google.com/____group/webpy?hl=en
<http://groups.google.com/__group/webpy?hl=en>>
<http://groups.google.com/____group/webpy?hl=en
<http://groups.google.com/__group/webpy?hl=en>
<http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>>>.
--
You received this message because you are subscribed
to the
Groups "web.py" group.
To post to this group, send email to
we...@googlegroups.com <mailto:we...@googlegroups.com>
<mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>__>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegrou__ps.com
<http://googlegroups.com>
<mailto:webpy%2Bunsubscribe@__googlegroups.com
<mailto:webpy%252Bunsubscribe@googlegroups.com>>.
For more options, visit this group at
http://groups.google.com/____group/webpy?hl=en
<http://groups.google.com/__group/webpy?hl=en>
<http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>>.
--
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de
<mailto:pat...@perdmann.de> <mailto:pat...@perdmann.de
<mailto:pat...@perdmann.de>>
--
You received this message because you are subscribed to the
Google Groups "web.py" group.
To post to this group, send email to
we...@googlegroups.com <mailto:we...@googlegroups.com>
<mailto:we...@googlegroups.com <mailto:we...@googlegroups.com>__>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegrou__ps.com
<http://googlegroups.com>
<mailto:webpy%2Bunsubscribe@__googlegroups.com
<mailto:webpy%252Bunsubscribe@googlegroups.com>>.
For more options, visit this group at
http://groups.google.com/____group/webpy?hl=en
<http://groups.google.com/__group/webpy?hl=en>
<http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com
<mailto:we...@googlegroups.com>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegroups.com
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>.
--
Mit freundlichen Grüßen
Patrick Erdmann
XMPP/Mail: pat...@perdmann.de <mailto:pat...@perdmann.de>
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com
<mailto:we...@googlegroups.com>.
To unsubscribe from this group, send email to
webpy+unsubscribe@__googlegroups.com
<mailto:webpy%2Bunsubscribe@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/webpy?hl=en
<http://groups.google.com/group/webpy?hl=en>.
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+unsubscribe@googlegroups.com.