Image Streaming
Steffen Brodowski
st.brodowski at eucrea.com
Wed Jul 9 10:22:04 EDT 2003
Hi Ian,
> >
> > import Image, ImageDraw
> > def CreateBarcode(SourceString,Linewidth,WriteText):
> > blablabla
> > ...
> > NewImage = Image.new("L",NewSize,Backcolor)
> > ImgDraw = ImageDraw.Draw(NewImage)
> > ....
> >
> > #How to put the image into an stream?
>
> have that function return the image object. Then, assuming you are
> doing this in CGI (easily adapted if not), do something like (untested):
>
> import sys
> image = CreateBarCode(...)
> print 'Content-type: image/jpeg\n'
> image.save(sys.stdout, 'JPEG')
I think its more difficult.
The function CreateBarcode has to return the image directly.
Additional you have to know, that I have to implement it into Zope. So
I use the script as an "external method". Modulname=Barcode,
functionname=CreateBarcode.
I'm using the following line in Zope DTML
<dtml-var "barcode(SourceString='123456789',Linewidth=1,WriteText=0)">
or
<img src="<dtml-var "barcode128(SourceString='123456789',Linewidth=1,WriteText=0)">">
to generate the barcode and for showing it on a html-site.
But is doesn't run.
Do you have any ideas?
Greetings
Steffen Brodowski
More information about the Python-list
mailing list