Generating Compressed or Uncompressed GIF Files with Barcode ActiveX

The most common graphic file format used in all web browsers is the GIF format. Unisys Corp. currently holds a patent on the LZW compression algorithm used in compressed GIF files and unfortunately, you are required to purchase a license from Unisys at a cost of between $5000 to $7500 if you want to generate true LZW compressed GIF files on a web server.

We had originally hoped that we would be able to purchase a license from Unisys for the TAL Barcode ActiveX control and extend that license to the users of our control however Unisys does not allow for this type of licensing. Because the TAL Barcode ActiveX control is considered a “development tool”, each user of the control is required to purchase their own license to use the LZW compression scheme. The TAL Barcode ActiveX control fully supports LZW compression in GIF files however this functionality must be enabled using a special “unlock key”. If you purchase a LZW license from Unisys, you can send TAL Technologies a copy of your license and we will provide you with a special “unlock key” that you can use in the LZWUnlockKey property of the control to unlock this functionality.

Note: The LZW Patent is due to expire in the July of 2003 after which the LZW compression scheme will enter the public domain and therefore not require you to purchase a license from Unisys.

The GIF specification technically does not support uncompressed GIFs however it is possible to create uncompressed GIFs that trick any program that can read GIF files into rendering them. If you do not purchase the LZW license from Unisys then you can only create uncompressed GIFs with the TAL Barcode ActiveX control (Plus version) however the file size of your GIFs will be much larger than an equivalent compressed GIF barcode image. The trick that must be employed to create uncompressed GIFs actually causes them to be up to four times as large as an equivalent uncompressed bitmap. Uncompressed GIFs are typically eight times larger than the same image saved as a compressed GIF. For example, a typical barcode that is three inches wide and one inch tall saved with a resolution of 300 pixels per inch with one bit per pixel will be roughly 150K bytes in size when saved as an uncompressed GIF. The same barcode saved using GIF compression will be roughly 17K bytes in size.

One technique that you can use to keep the size of your uncompressed GIFs to a minimum is to create the barcode with a very small height like 100 mils (one tenth of an inch) and then stretch the barcode height using a higher value in the Height setting in the image tag in your HTML code. If you create the same three inch wide barcode as above using a height of 100 mils (one tenth of an inch) instead of the full one inch, you will cut the size of the file down by a factor of ten. When you set the height setting in your HTML code to a value (in pixels) that is equivalent to one inch, the browser will stretch the height of the image to the desired size. Because all of the information encoded in a barcode is contained in the widths of the bars and spaces and not in the height, stretching the height will not degrade the readability of the barcode. Using this technique, you can drastically reduce the download time for both compressed and uncompressed GIF files. In the example above, our unreasonably large 150K byte uncompressed GIF barcode image file drops in size to 15K bytes which is a perfectly reasonable file size for a web based GIF image.

Note: The PNG file format is an excellent alternative to the GIF file format. PNG files are highly compressed using an algorithm that is in the public domain therefore no license fee is required to use them. Most browsers including Netscape 4.0, Internet Explorer 4.0, and all newer releases of both, fully support PNG files. The same three inch by one inch barcode as in the above example squeezes down to an image file size of under 1000 bytes when saved as a PNG file. This is remarkably good compression considering that the smallest possible size for an uncompressed three inch by one inch, 300 DPI, raster image with 1 bit per pixel is 33750 bytes. (Almost a 35 to 1 compression ratio!)

Contact Us