Comments (3)
Hello @endroid
Thank you for your answer.
I have tried without xdebug, and the difference is huge.
There is now no notable difference between v5.0.7 and v1.9 :)
from qr-code.
In order to compare code for
- version 1.9
$qr_code = new QrCode();
$qr_code
->setText( $_REQUEST['url'] )
->setSize( 280 ) // 300x300 = 150x150 (Student Photo) scale 2x.
->setPadding( 10 )
->setErrorCorrection( 'high' )
->setForegroundColor( ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0] )
->setBackgroundColor( ['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0] )
->setLabel( ! empty( $_REQUEST['label'] ) ? $_REQUEST['label'] : '' )
->setImageType( QrCode::IMAGE_TYPE_PNG )
;
// now we can directly output the qrcode
header( 'Content-Type: ' . $qr_code->getContentType() );
$qr_code->render();
- version 5.0.7 (or 4.4.7 is almost the same)
$qrCode = QrCode::create( $_REQUEST['url'] )
->setEncoding( new Encoding( 'UTF-8' ) )
->setErrorCorrectionLevel( ErrorCorrectionLevel::High )
->setSize( 280 )
->setMargin( 10 )
->setForegroundColor( new Color( 0, 0, 0 ) )
->setBackgroundColor( new Color( 255, 255, 255 ) );
// Create generic label
$label = Label::create( ! empty( $_REQUEST['label'] ) ? $_REQUEST['label'] : '' )
->setTextColor( new Color( 0, 0, 0 ) );
$writer = new PngWriter();
$result = $writer->write( $qrCode, null, $label );
// Directly output the QR code
header( 'Content-Type: ' . $result->getMimeType() );
echo $result->getString();
from qr-code.
Hi @francoisjacquet, when I run your last snippet here (exactly as you placed it) the code generates in approximataly 10ms. Of course I have different hardware here, but this difference is so big I think something else is going on, so I'm curious what is causing the performance issue on your side.
I don't know your exact url
and label
, can you provide those values to make sure it is not caused by specific values? Also, please check if you do not have underlying processes like xdebug running. And if it is really hard to find you could try to use a profiler like Blackfire. Such a tool makes finding the underlying cause a lot easier most of the cases.
from qr-code.
Related Issues (20)
- Release Notes for Version 5 HOT 2
- Invalid image in README.md HOT 1
- Specifying QR code models HOT 2
- [Feature Request] PdfWriter sub-millimeter block size
- vcards HOT 1
- Problems using library HOT 1
- imagettfbbox(): Could not find/open font HOT 6
- Expected type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface'. Found 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'. HOT 1
- PArameter documentation HOT 2
- Background color and margin for logo HOT 1
- How can I add an image with input type file? HOT 1
- Message: Interface "Endroid\QrCode\QrCodeInterface" not found HOT 1
- Modifying cells of the matrix HOT 3
- how to set the version of a qrcode HOT 1
- Question : how is it possible not displaying the label (for accessibility reasons) ? HOT 2
- Call to undefined method Endroid\QrCode\QrCode::create() HOT 3
- Image embedded in email contains full path to image HOT 2
- Could it be that the readme is outdated? HOT 2
- [Feature Request] SvgWriter with choice of code generation policy - Option to Use Previous SVG Generation Method with <defs> HOT 4
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 qr-code.