Hi Frederico,

the code you took to start with isn't that bad, but it's originally used for a doodling demo which has a uniform white background (which is something that you won't have) so the protocol used will inflate the uncompressed image data you have by a factor of at least 3.5 !

Since you POST anyway maybe better use a binary format which:
- gets rid of the useless (at least for sending webcam images) pseudo-compression (removing a uniform background color - which you won't have) scheme - avoids encoding the data as an ASCII string (which inflates the size of the data by at least 3.5 times)
for better performance / less data to transfer?

The easiest way would be to put something in the flash applet which outputs something that can be directly fed to Image.fromstring or Image.frombuffer.

After getting that to work you can then add some sort of real compression, here's some fodder for you to get started:
http://www.razorberry.com/blog/archives/2004/08/22/lzw-compression-methods-in-as2/
http://newmovieclip.wordpress.com/2006/05/15/image-compression-possibilities-in-flash-8/

The problem you will have is that LZW isn't that good performing (in terms of compression rate) on stuff like video images... so better code it in a way that you can plug-in another, better suited compression scheme later.
But it'll be better than encoding it in ASCII for sure :)

Regards,

  Gregor


Frederico Leonardo schrieb:
Hi all,

I've only recently started using Python via Django and so far I'm loving it.
I have a question that hopefully someone might be able to answer. I've
scouted the internet looking for this but can't manage to find the
right example.

I'm creating an e-card application in Django. Some of the e-cards are
SWF with a script that reads your webcam and then produces a new card
with the webcam information. Flash is working fine and it's sending me
variables to construct the new image. I can already get the width and
height:

card_width = int(request.POST.get('width',''))
card_height = int(request.POST.get('height',''))

But I have no idea how to convert the rest of the information into an
image, let alone draw and save it.

This is what Flash is sending me via 'POST':

Variable: px19  
Value: 
u',,,,,,,,,,,,,,,,,,,,,,,,,,,,,eeffff,abcae7,8baece,6c90b0,6b8faf,698bae,6789ae,(...)

It repeats this for every px# and is also sending me rows and cols,
besides the width and height. Those values are hex and I suppose that
they correspond to the rows, each color being 1 pixel per column.
I came across this technique here:
http://www.sephiroth.it/tutorials/flashPHP/print_screen/page002.php
But alas, it's a PHP script, that I would very much love to reproduce using PIL.

How can I grab that information into an array and then have PIL
convert it into a JPG that I can save on the server. Any ideas?

Thank you!

— Frederico
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

begin:vcard
fn:Gregor Kopka
n:Kopka;Gregor
org:Kopka.Net;Internet Services
adr:;;Grosse Strasse 10;Ahrensburg;;22926;Deutschland
email;internet:gre...@kopka.net
title:Inhaber
tel;work:+49 4102 823212
tel;fax:+49 4102 823213
tel;cell:+49 174 2550492
x-mozilla-html:FALSE
url:http://kopka.net
version:2.1
end:vcard

_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to