Open bilogic opened 3 years ago
Was a white boarder added to the second image? I agree it looks better and wouldn't be difficult to add.
No, I fired up photoshop to show what I wanted :)
So all I'm trying to say is, can we add the logic to white out parts of the QR code where the logo will overlap? Of course at the same time, also center the logo so that the white border is symmetrical on all sides.
I really like it 😄. I should have some extra time this week to add this but if you beat me to a PR I'll accept it as well.
Haha ok, hmm I don't mind, but I'm not familiar with your codebase. Can give me a few pointers on where to look?
The qrcode merging happens in the ImageMerge
file (https://github.com/SimpleSoftwareIO/simple-qrcode/blob/develop/src/ImageMerge.php). It's pretty simple overall as it takes the qrcode and just overlays the image.
I think this feature would be as easy as adding a boarder around the merging image. The boarder color should likely match the background color.
As far as the merge
property (done in the Generator
class), maybe something like this would be best to allow for the old and new methods:
merge(string $filepath, float $percentage = .2, bool $absolute = false, int $borderSize = 0, int $boarderRoundness = 0): self
. Where boarderRoundness is how round the corners of the image should be.
I'm open to ideas though!
Ok, let me take a look shortly. Thank you.
Just to clarify, my "algo" was to zero out the qrcode matrix to get enough space in the center before inserting the logo into it. Is https://github.com/SimpleSoftwareIO/simple-qrcode/blob/develop/src/ImageMerge.php still the place to look?
Adding a border won't achieve the same look, in fact, we can now add a border to the logo and get the same effect.
TBH, I'm currently using Endroid/qr-code, but they are not fluent, and then I found yours.
I saw a matrix somewhere ($baconQrCode->getMatrix();
) but stopped because I'm about to switch over to yours.
So my question would be, where is a suitable place to be aware of the logo aspect ratio, the qrcode matrix and the required output dimensions? Thank you.
@SimplyCorey
QrCode::erase(...)
Encoder::encode
erase()
is for)Endroid
(matrix was quite accessible there)From what I can tell, it is quite a bit of change for simple-qrcode
, I thought it is better to get your inputs before I proceed. Thank you.
@bilogic Thanks for the details. I see how you want to approach this and that makes sense as a simple border laid over top will cause the same issue. I'll have to think about this some as this will likely require dropping down into bacon to clear the matrix.
I was able to throw together a quick proof of concept.
I don't have any more time today to work on it but I think this will be pretty easy to get done.
I'm able to get the module size from the Renderer which is used to delete the erase the matrix in the areas I need to.
@SimplyCorey ok just want to share this was how I calculated inside endroid
// $rowCount = xxx; // total rows of matrix
// $colCount = xxx; // total columns of matrix
$erase_row = (($columnCount * 0.25 / 2) * 2) + 1; // erase 25% height and get a odd number
$erase_col = (($columnCount * 0.25 / 2) * 2) + 1; // erase 25% width and get a odd number
$rowCount = ($rowCount - $erase_row)/2;
$columnCount = ($columnCount - $erase_col)/2;
for ($rowIndex = $rowCount; $rowIndex < $rowCount + $erase_row; ++$rowIndex) {
for ($columnIndex = $columnCount; $columnIndex < $columnCount + $erase_col; ++$columnIndex) {
$matrix[$rowIndex][$columnIndex] = 0;
}
}
@SimplyCorey a few more related matters
any update on this I need to archive the same result.. thanks
Hi, any update on this please? Thank you.
Possible to remove overlapping parts of the qrcode?