picqer / php-barcode-generator

Barcode generator in PHP that is easy to use, non-bloated and framework independent.
GNU Lesser General Public License v3.0
1.66k stars 400 forks source link

Add the ability to set margins #123

Open nicolasvac opened 3 years ago

nicolasvac commented 3 years ago

Hello everyone, we are actively using this library to generate barcodes, and we found out that some mobile devices have troubles reading it because there is no ability to set margins around the image, to give a bit of space before starting to read the lines.

While i know a simple solution like this can be applied:

      $generatedImage = new Imagick();
      $generatedImage->readImageBlob($barcodeGenerator->getBarcode(xx));
      $generatedImage->borderImage('white', 20, 20);

      $barcode = $generatedImage->getImageBlob();

It would be nice to have the ability for both SVG, PNG and JPG to set the margins. Thank you.

casperbakker commented 2 years ago

Yes that would be nice. I think the current interface does not work for these kind of options. But I am exploring options to divide the barcode encoding and the image rendering parts. That would make it easier to differentiate the image renderers.

osflake commented 3 months ago

Any changes? Please @casperbakker some feedback