473,545 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image Streaming

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 "CreateBarc ode" 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(S ourceString,Lin ewidth,WriteTex t):
blablabla
...
NewImage = Image.new("L",N ewSize,Backcolo r)
ImgDraw = ImageDraw.Draw( NewImage)
....

#How to put the image into an stream?

best regards

Steffen Brodowksi
Germany
Jul 18 '05 #1
9 7339

Uzytkownik "Steffen Brodowski" <st**********@e ucrea.com> napisal w
wiadomosci news:38******** *************** ***@posting.goo gle.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 "CreateBarc ode" 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(S ourceString,Lin ewidth,WriteTex t):
blablabla
...
NewImage = Image.new("L",N ewSize,Backcolo r)
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

Jul 18 '05 #2
On Tue, 2003-07-08 at 02:26, Steffen Brodowski wrote:
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 "CreateBarc ode" 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(S ourceString,Lin ewidth,WriteTex t):
blablabla
...
NewImage = Image.new("L",N ewSize,Backcolo r)
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')

Ian

Jul 18 '05 #3
Fernando Perez <fp*******@yaho o.com> schreef:
or even gif (the patents expired recently).


Only in the US, not in (some countries in) Europe & Japan.

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
Jul 18 '05 #4
Fernando Perez wrote:
For barcodes, use png, tiff or even gif (the patents expired recently).


note that PIL's GIF generator uses run-length encoding, so the
Unisys LZW patents won't matter here.

</F>


Jul 18 '05 #5
Hi Ian,


import Image, ImageDraw
def CreateBarcode(S ourceString,Lin ewidth,WriteTex t):
blablabla
...
NewImage = Image.new("L",N ewSize,Backcolo r)
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=Barco de,
functionname=Cr eateBarcode.

I'm using the following line in Zope DTML
<dtml-var "barcode(Source String='1234567 89',Linewidth=1 ,WriteText=0)">
or
<img src="<dtml-var "barcode128(Sou rceString='1234 56789',Linewidt h=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
Jul 18 '05 #6
On Wed, 2003-07-09 at 09:22, Steffen Brodowski wrote:
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=Barco de,
functionname=Cr eateBarcode.

I'm using the following line in Zope DTML
<dtml-var "barcode(Source String='1234567 89',Linewidth=1 ,WriteText=0)">


So then you don't want to stream it. You might do something like:

from cStringIO import StringIO
def CreateBarcode(. ..):
# create image object
output = StringIO()
image.save(outp ut, 'GIF')
return output.getvalue ()


Jul 18 '05 #7
JanC wrote:
Fernando Perez <fp*******@yaho o.com> schreef:
or even gif (the patents expired recently).


Only in the US, not in (some countries in) Europe & Japan.


Ah, you're right. But I think they also expire soon, don't they? Well, anyway,
png is better :)

Best,

f.
Jul 18 '05 #8
Fernando Perez <fp*******@yaho o.com> schreef:
or even gif (the patents expired recently).


Only in the US, not in (some countries in) Europe & Japan.


Ah, you're right. But I think they also expire soon, don't they?


Somewhere next year IIRC (at least in most countries).

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
Jul 18 '05 #9
Hi Ian,
from cStringIO import StringIO
def CreateBarcode(. ..):
# create image object
output = StringIO()
image.save(outp ut, 'GIF')
return output.getvalue ()


Yes, it works! Thank you!!

Steffen Brodowski
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2915
by: Jason Murry | last post by:
I have a camera system (Axis) which stores JPG via FTP 1-10fps. There is also a motion jpg live stream. I am trying to store these images either in JPG or in video format so they can be reviewed at a later date. I would need to be able to pull a date-time range from the list. This means 86,400 - 2,160,000 images (around 110Kb a piece)...
4
2819
by: malcolm | last post by:
I've seen several posts around the Internet and many of them either don't work or only partially work. All I'm trying to do is record some action asynchronously from an html file, a sort of logging mechanism. The product is a CD catalog that will be delivered to many customers and they want the ability to log specific pages accross the...
0
3347
by: Jerry J | last post by:
I have a third party image viewer that can display various types of images. The image viewer is ActiveX and lives inside of Internet Explorer. To get the image viewer to retrieve an image, java script on the client looks something like this: VIEWER.GetImage("http://www.url.com/SomeImage.jpg")...
4
2838
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and select Save Target as..., but the button might be a more intuitive way.
1
1595
by: BluDog | last post by:
Hi I have a class that has a System.Drawing.Image as a property, i would like to display this image on my WebForm, however i think i need to get it into a System.Web.UI.WebControls.Image object, but i cannot work out how do conver it. Any ideas? Thanks
1
1435
by: Stephen | last post by:
Hi, I am using an Access database (OLE Object) and storing Image as a bytes after streaming. I am able to read it back as a stream and display it on the browser using the following code: Response.OutputStream.Write(fileData, 0, fileData.Length) it displays on the browser as an image, but I want to display it in an Image (web control...
3
12248
by: Tom John | last post by:
Hi I am using Office Web Components to generate a GIF image, which i want to display in a picture box. However i am having a problem when i attempt to load the image into the picture box. Firstly i was saving the image using the Chartspace Export and passing the path to the PictureBox load, however i think that the image is not saved...
4
3804
by: Greg | last post by:
I've searched everywhere for a solution Microsoft .NET Framework V 2.0.50727 AutoEventWireup="false" image2.aspx resize an image on the fly but Page_Load is triggered twice: Any suggestion? Here is the code behind:
0
3154
by: =?Utf-8?B?RG9jdG9y?= | last post by:
I am making an application that streams video from a web camera onto the client area of a PictureBox on a Windows CLR Form in MS Visual Studio 2005 (using C++). The streaming video works fine, and now I am trying to create an image overlay. I am assuming that the best way for me to do this is to create a second PictureBox that lays over the...
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.