tecnickcom/tc-lib-barcode

Imporve quality of PNG ??

Diamond7 opened this issue · 4 comments

I need to improve quality definition of PNG barcode, how to achieve it ?

Changing width and height will produce a big image with more resolution.
If you are trying to create a qr code, putting less data in "code" will make easy to read.

The resolution must be decided by the size and application you are trying to achieve. If you are printing on paper or screen, make it large enough not to be resized upwards.
I tried a few things to make the barcode / QR code easier to read.

  • White backgroud with black barcode.
  • A 5mm margin of anything around
  • Use good reading software. Typically, the feature in Google Lens reads very good on Android phones,
  • Put less data.

Hope, it helps!

From the getBarcodeObj() documentation:

* @param int    $width   Barcode width in user units (excluding padding).
*                        A negative value indicates the multiplication factor for each column.
* @param int    $height  Barcode height in user units (excluding padding).
*                        A negative value indicates the multiplication factor for each row.

So you can set these values explicitly or as multiplication factor to get the desired resolution.