Barcode Bakery Blog

Detailed Barcode Tutorials

Month: December 2011

Scale vs DPI

Scale

Scale is the unit used when displaying an image on a computer screen, mobile phone, etc.

When setting the scale to 1, it represents the smallest unit that can be displayed on the screen. In 1D barcodes, this means each vertical black bar will be represented by a one pixel wide line. If you set a scale of 2, the vertical bar will be represented by a two pixel wide line, and so on.

This is the same concept for 2D barcodes: a black bit will be 1×1 pixels for scale of 1, and 2×2 pixels for scale of 2.

As you can see, it is not possible to choose a scale between 1 and 2 since a barcode cannot be written using 1.5 pixel sizes.

The size of the barcode itself will depend on the resolution and screen size of your user. For a same monitor size, if you compare a screen resolution of 1600×1200 and 800×600, the barcode will appear smaller to the eye on the first screen than the second.

This property can be set with the method “setScale(2)” from any barcodes.

As shown below, a larger scale will increase the size of the image displayed.

Scale 2 - DPI 72

Scale 2 – DPI 72

Scale 3 - DPI 72

Scale 3 – DPI 72

DPI (dot per inch)

This unit of scaling is for printing. This will tell your image how many “dots” (pixels) will be printed within one inch on paper. The default value is 72. The value usually used for printing is 300.

If you take two images with the same scaling (the images look exactly the same on the screen) but with a DPI of 72 and a DPI of 300, the first image will appear larger than the second one on paper. However, if your printer supports 300 DPI correctly, the second image will have a better quality than the first one.

This property can be set on the BCGDrawing object with “setDPI(300)”.

Two images of the same scale and different DPI’s will be displayed the same way on a screen:

Scale 3 - DPI 72

Scale 3 – DPI 72

Scale 3 - DPI 300

Scale 3 – DPI 300

Conclusion

If you plan to print your barcode, you must consider the setDPI() method. If you only display the image on the screen, then you would never need to use setDPI() and only the setScale() method.

If you want to have a bigger image than scale 1 but smaller than scale 2, you would need to resize the image with resampling. Doing so will introduce anti-aliasing in your image and possibly problems to read the barcode. Introducing anti-aliasing into an image means one bar for a 1D barcode will not be as clear as 1 pixel; it may be 1 pixel black, and 1 pixel gray.

If you still want to resize your barcode, you can use the method imagecopyresampled() from PHP by getting the image resource from the BCGDrawing with the method get_im().

Choosing the Right Barcode

1dor2dIn this first blog post, you will learn how to choose the right barcode. There are multiple available and some may suit more your needs than others. Gather your requirements and start reading.

Selling an item?

This is an easy first question to consider: are you selling this item? If no, skip this part. Yes? then you may want to consider the barcodes that are used in commercial fields such as:

  • UPC-A, UPC-E
  • EAN-13
  • Databar Expanded (coupon)

Data to Encode

One of the first requirements you should gather is the type of data you will encode in the barcode. Do you want to encode numbers, letters, or special characters? Not all barcode standards support the full ASCII. Make sure to read the manual of each of format to see which barcode will be able to support your data.

Size

A particular size of barcode may be necessary for your needs. Different types of barcodes vary in size and shape. Some standards also allow for more size constraints to be added. Each standard allows a sample demonstration which should be used to test the size and shape of images you are trying to create.

Error Correction

Error correction within barcodes is very useful when you aren’t sure of the printer quality of the person printing the barcode or if you feel that your barcode may be slightly damaged (due to rips or tears in paper, fading from sunlight, etc.). Error correction can compensate for minor flaws in barcode printing or when a part of the barcode is covered when scanned.

1D or 2D

1D barcodes are much simpler than 2D barcodes. 2D barcodes generally allow for error correction and a much wider range of character use. 1D barcodes are great for coupon codes or small amounts of information and 2D barcodes are great for links, large amounts of data, and mobile tagging.

 

Following this guide should help you to select the most efficient barcode for your needs.

 

 

© 2024 Barcode Bakery Blog

Theme by Anders NorenUp ↑