What does this error mean?

Hey guys,

I’m getting this error on my Prestashop website.

The function is surposed to optimise images on my website and resave them into their current directories.

Fatal error: Uncaught exception 'Exception' with message 'Unable to save image: 1' in /home/diysecur/public_html/modules/prestaspeed/SimpleImage.php:905 Stack trace: #0 /home/diysecur/public_html/modules/prestaspeed/prestaspeed.php(315): abeautifulsite\SimpleImage->save(1, 100) #1 /home/diysecur/public_html/modules/prestaspeed/prestaspeed.php(523): PrestaSpeed->smushallgd('../img/p/', '\n\t \t<div class=...') #2 /home/diysecur/public_html/modules/prestaspeed/prestaspeed.php(3287): PrestaSpeed->postProcess() #3 /home/diysecur/public_html/controllers/admin/AdminModulesController.php(846): PrestaSpeed->getContent() #4 /home/diysecur/public_html/controllers/admin/AdminModulesController.php(1094): AdminModulesControllerCore->postProcessCallback() #5 /home/diysecur/public_html/classes/controller/Controller.php(171): AdminModulesControllerCore->postProcess() #6 /home/diysecur/public_html/classes/Dispatcher.php(373): ControllerCore->run() #7 /home/diysecur/public_html/admin123/index.php(54): DispatcherCore->dispatch() #8 {main} in /home/diysecur/public_html/modules/prestaspeed/SimpleImage.php on line 905
[PrestaShop] Fatal error in module file :/home/diysecur/public_html/modules/prestaspeed/SimpleImage.php:
Uncaught exception 'Exception' with message 'Unable to save image: 1' in /home/diysecur/public_html/modules/prestaspeed/SimpleImage.php:905 Stack trace: #0 /home/diysecur/public_html/modules/prestaspeed/prestaspeed.php(315): abeautifulsite\SimpleImage->save(1, 100) #1 /home/diysecur/public_html/modules/prestaspeed/prestaspeed.php(523): PrestaSpeed->smushallgd('../img/p/', '\n\t \t
postProcess() #3 /home/diysecur/public_html/controllers/admin/AdminModulesController.php(846): PrestaSpeed->getContent() #4 /home/diysecur/public_html/controllers/admin/AdminModulesController.php(1094): AdminModulesControllerCore->postProcessCallback() #5 /home/diysecur/public_html/classes/controller/Controller.php(171): AdminModulesControllerCore->postProcess() #6 /home/diysecur/public_html/classes/Dispatcher.php(373): ControllerCore->run() #7 /home/diysecur/public_html/admin123/index.php(54): DispatcherCore->dispatch() #8 {main}

It means exactly what it says :smile:

Unable to save image

Check writing permissions for the folder where images are stored by your CMS.
Maybe it just can’t save uploaded files due to lack of permission.

It means exactly what it says

LOL, yes I thought this also.

Would it be due to any of my PHP settings?

Looks like this is the class you get error in.

It tries to save image:

$result = imagejpeg($this->image, $filename, round($quality));

and then checks for result:

if (!$result) {
    throw new Exception('Unable to save image: ' . $filename);
}

As we can see from your error message you have “1” in $filename variable:

Unable to save image: 1

That is incorrect because $filename should contain something like /path/to/folder/file.jpg but it has only number inside. That number comes from /modules/prestaspeed/prestaspeed.php line 315.

I can’t guess why this is happening, some research and debugging required here.

I can’t guess why this is happening, some research and debugging required here.

Purchased the Module from a Developer on Code Canyon but have had little luck communicating with him.

The source code in question looks to be on line 905

        // Create the image
    switch (strtolower($format)) {
        case 'gif':
            $result = imagegif($this->image, $filename);
            break;
        case 'jpg':
        case 'jpeg':
            imageinterlace($this->image, true);
            $result = imagejpeg($this->image, $filename, round($quality));
            break;
        case 'png':
            $result = imagepng($this->image, $filename, round(9 * $quality / 100));
            break;
        default:
            throw new Exception('Unsupported format');
    }

    if (!$result) {
        throw new Exception('Unable to save image: ' . $filename);
    }

    return $this;

}

Yes, I saw that code.
The roots of the problem is not here. This function receives wrong value in $filename, passed from prestaspeed.php

Yes, I saw that code.
The roots of the problem is not here. This function receives wrong value in $filename, passed from prestaspeed.php

Funny you should say that as there is no “$filename” variable in “prestaspeed.php”

Only

$file
$files
$files2
$fileschunk

See for yourself :smile:

prestaspeed.zip (1.1 MB)

Some of my image files are 644 but the directory is 755

Could this be the issue?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.