Welcome Guest, Not a member yet? Register   Sign In
Allowed memory size exhausted when using image service
#1

I'm using the image library to store an image on the server, all works well until I send an image of this dimension: 5184 x 3456
This is the function that I've created to store the image:

PHP Code:
    protected function storeImage(string $pathstring $fileNamestring $widthstring $height)
    {
        $imgServ = \Config\Services::image();

        $ext pathinfo($fileNamePATHINFO_EXTENSION);
        $uploadPath $path basename($fileName".{$ext}") . "_{$width}x{$height}." $ext;
        $imgServ
            
->withFile(ROOTPATH 'public/' $path $fileName)
            ->fit(10241024'center')
            ->save(ROOTPATH 'public/' $uploadPath);

        return $uploadPath;
    
than I got:
<br />

<b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in <b>/var/www/html/vendor/codeigniter4/framework/system/Images/Handlers/GDHandler.php</b> on line <b>220</b><br />
<br />
<b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in <b>/var/www/html/vendor/codeigniter4/framework/system/Log/Handlers/FileHandler.php</b> on line <b>1</b><br />


how can I fix this?
Reply
#2

Fixing PHP Fatal Error: Allowed Memory Size Exhausted
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB