endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.33k stars 721 forks source link

Modifying cells of the matrix #433

Closed bilogic closed 6 months ago

bilogic commented 6 months ago

In v3.9.x, I extend the QrCode class to punch out QR code blocks nicely, i.e. I don't just paste a logo over the center, I actually remove whole cells of the QR code so that there is a clean area for pasting a logo.

How can I do this in 5.0?

bilogic commented 6 months ago

It is practically impossible to perform custom punch outs since there are final classes everywhere and AbstractGdWriter directly instantiates MatrixFactory to create $matrix and renders the image all in 1 go in write(...).

bilogic commented 6 months ago

In order to have a nicely laid out QR Code, certain info such as block_size and pixel count are required so that we can adjust the logo and label accordingly. However, I can't see a way to share that information elegantly based on how builder::build() is currently structured.

bilogic commented 6 months ago

After much experimentation, a small refactor in AbstractGdWriter can help make it customization. Hope the PR can be accepted. Thank you.