Comments (4)
This should be fixed with the new PNG renderer in version 2.0.0, by the way.
from baconqrcode.
I just took a couple of minutes to look into the issue (I didn't touch this library in a while), which is actually rather complicated. To break it down: The renderer will add a quiet zone to make sure that each single block takes up a fixed amount of pixels.
In your second QR code, there are 73 blocks in both directions. Given an image size of 210, which does not fit a block size of 3 pixels, it has to add padding so it can place blocks with a size of 2 pixels.
There is no proper way to work around this in the library. The best you can do, if you want consistent bitmap sizes and no quiet zone, is to render the image in a higher resolution (like, twice as big), then trim the image borders (Imagick can do that with a single method call) and then downscale it to 210 pixels, which would give you anti-aliased blocks.
If you have any further comments or ideas, feel free to re-open this issue.
from baconqrcode.
ok, thanks for looking into it.
do you know if there's a certain attribute of renderer class that would tell me that extra padding was applied?
from baconqrcode.
Nope, the renderers won't tell you that. But as I said, this is what you can do:
// Create writer with size 420…
$image = new Imagick();
$image->readImageBlob($writer->writeString('…'));
$image->trimImage(0);
$image->resizeImage(210, 210, Imagick::FILTER_CATROM, 1);
$image->writeImage('qr-code.png');
from baconqrcode.
Related Issues (20)
- Somtimes weird renderings HOT 4
- Implicit conversion from float to int HOT 3
- Caught exception: Could not encode content to H
- Very poor quality rounding?
- Slow $writer->writeFile locally, didn't test on the server HOT 3
- [request]: GD support for image generation HOT 6
- Alpha generating an all blank qr code. HOT 3
- How to use transparent background?
- Unable to set image format error HOT 1
- BUG? on this line $j is always 0, isn't this meant to be $i ? or actually 0? HOT 2
- Generating Qr Code
- Division by zero error HOT 1
- Broken style when exporting rounded qr code as eps
- BaconQrCode does not work correctly with Cyrillic alphabet. HOT 1
- Does anyone know how to Achieve different type of shapes or bits except Square or circle.
- RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 {"userId":1,"exception":"[object] (ImagickException(code: 495): RegistryKeyLookupFailed `CoderModulesPath' @ error/module.c/GetMagickModulePath/667 at C:\\Users\\XavierPalacín\\Projects\\engel\\vendor\\bacon\\bacon-qr-code\\src\\Renderer\\Image\\ImagickImageBackEnd.php:75) HOT 1
- Kanji Mode QR code is broken
- Use of deprecated constant MT_RAND_PHP in tests HOT 2
- Error : You need to install the imagick extension to use this back end HOT 1
- Add external libraries that use Composer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baconqrcode.