Image Streaming

Fernando Perez fperez528 at yahoo.com
Tue Jul 8 13:06:55 EDT 2003


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 "CreateBarcode" should write the jpg
> data into an outstream. All barcodes will be generate online, without
> saving the jpgs on harddisk.

Just a side comment:  jpg is the absolutely worst possible format you could use
for barcodes.  jpg suffers from aliasing (see Gibbs phenomenon in any numerical
analysis or Fourier series textbook), which you see as 'ringing shadows' around
sharp black/white transitions.  JPG was designed for smooth color, photographic
images.  It was a format designed to approach the exact opposite end of the
image spectrum than a barcode is.

For barcodes, use png, tiff or even gif (the patents expired recently).

If this is just an exercise in learning python, then it doesn't matter.  But if
you care about the quality of your generated barcodes (or black/white images in
general, such as scanned text), never use jpg for that.  

If you are for some reason absolutely forced to use jpeg, then use as high a
'quality factor' as you can afford.  It will give you very large files, but at
least the problems won't be as noticeable.

Best,

f.




More information about the Python-list mailing list