SimpleSoftwareIO / simple-qrcode

An easy-to-use PHP QrCode generator with first-party support for Laravel.
https://www.simplesoftware.io/simple-qrcode
MIT License
2.72k stars 383 forks source link

Execution time out when trying to add a logo over the qr code #292

Closed marcelosantos89 closed 1 year ago

marcelosantos89 commented 1 year ago

Hey, i was trying to dynamicly have a logo over the qr code or not but when i add a logo it times out.

i have the following code:

protected function generateQrCode($format = 'png')
    {
        $filename = 'qrcodes/qrcode_' . $this->model->slug .'.png';

        $qrCodeImage = QrCode::format($format);
        $qrCodeImage = $qrCodeImage->size(1000)->margin(1);

        if($this->model->settings['logo']) {
            $qrCodeImage = $qrCodeImage->errorCorrection('H')
                                ->mergeString(Storage::disk('public')->get($this->model->settings['logo']), .25);
        }

        $qrCodeImage->generate($this->getData(), './storage/'. $filename);
        return $filename;
    }

but if I run this

$qrCodeImage->errorCorrection('H')
     ->mergeString(Storage::disk('public')->get($this->model->settings['logo']), .2)
     ->generate($this->getData(), './storage/'. $filename);

this runs fine. Any suggestions?

Forgot to mention, the qr code still gets generated but it never returns anything gets stuck somewhere and so it fails for time execution...

most of the times the error shows this:

public function done() : string

    {

        if (null === $this->draw) {

            throw new RuntimeException('No image has been started');

        }

        $this->image->drawImage($this->draw);

        $blob = $this->image->getImageBlob();

        $this->draw->clear();

        $this->image->clear();

        $this->draw = null;

        $this->image = null;

        $this->gradientCount = null;

        return $blob;

    }

Thanks