Image Streaming

piter tojopiter at yahoo.com
Tue Jul 8 10:12:21 CEST 2003


Uzytkownik "Steffen Brodowski" <st.brodowski at eucrea.com> napisal w
wiadomosci news:381a2b17.0307072326.211c21b5 at posting.google.com...
> Hello everyone,
>
> since one week, I'm programming with python. Its a realy interesting
> tool. I wrote a script for generating barcodes in jpg-format.
> Everything is ok, but my function "CreateBarcode" should write the jpg
> data into an outstream. All barcodes will be generate online, without
> saving the jpgs on harddisk.
>
> Can you give me a tip witch objects I need and how to put the jpg into
> an outgoing stream?
>
> 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?

Image.save
save(outfile, options)
save(outfile, format, options)
Saves the image under the given filename. If format is omitted, the format
is determined from the filename extension, if possible. This method returns
None.
Keyword options can be used to provide additional instructions to the
writer. If a writer doesn't recognise an option, it is silently ignored. The
available options are described later in this handbook.
You can use a file object instead of a filename. In this case, you must
always specify the format. The file object must implement the seek, tell,
and write methods, and be opened in binary mode.

hth
Piter
>
> best regards
>
> Steffen Brodowksi
> Germany






More information about the Python-list mailing list