Skip to content
← All PrestaShop 9 errors

PrestaShop 9 errors

Cannot write images for this type: products, when regenerating thumbnails in PrestaShop 9

Thumbnail regeneration stops with a message about folder permissions. In PrestaShop 9 the same message appears when any single image fails for any reason, so permissions are only one of the possible causes.

The error
Cannot write images for this type: products. Please check the /img/p/ folder's writing permissions.
Appears
Design > Image settings > Regenerate thumbnails (9.x)
Usually found in
Large original photos, img/p folder owners, PHP memory_limit

What happened

When you regenerate thumbnails, PrestaShop 9 goes through every product image, every image type and every format you enabled (JPEG, plus WebP or AVIF if selected). Each failure adds a detailed note, for example Original image is corrupt (…) for product ID 12 or bad permission on folder. The command handler then throws that list away and shows one general sentence about write permissions.

So one bad image among thousands is enough for this message. We checked the code of 9.2, and on our 9.2 test store resizing failed with it in these cases:

  • The original is too large for the PHP memory limit. Before resizing, PrestaShop estimates the memory needed (width × height × colour channels, times 1.8) and refuses the image if it would not fit in memory_limit. A 48-megapixel photo (8000 × 6000) was refused with memory_limit = 256M and resized with 1G. Many phone cameras take 48 MP photos now.
  • A folder under img/p is not writable by the PHP user, for example a folder created by root, by another FTP user or during a migration. The parent folder can look fine with 755 while one subfolder belongs to someone else.
  • The original file is missing or empty.

The fix: find the image that fails

Start with the large originals. File size is only a hint, since the pixel count is what matters:

find img/p -regex '.*/[0-9]+\.jpg' -size +5M
php -r 'print_r(getimagesize("img/p/1/2/12.jpg"));'

If you find a very large photo, either resize the original or raise memory_limit (for example to 1G) for the regeneration and set it back afterwards.

Then the owners and the empty files (use your web server user instead of www-data):

find img/p ! -user www-data | head
find img/p -regex '.*/[0-9]+\.jpg' -size 0

Regenerate one image type at a time, with Erase previous images turned off. PrestaShop skips thumbnails that already exist, so each run continues where the last one stopped, and the problem image is easier to spot.

Where else it hides

If AVIF is selected in the image formats but the server's GD has no AVIF support, resizing does not fail politely: it ends with Call to undefined function imageavif(). The settings page normally greys out AVIF when it is not supported. This shows up after a store is moved to a server whose PHP lacks it. Turn AVIF off in Design > Image settings, or ask the host for a GD build with AVIF.

Upgrading anyway? Know what breaks next

This error comes from the server or the upgrade itself, not from your modules. The next ones usually do: modules, the theme and overrides that still call code PrestaShop 8 and 9 removed. Our free PrestaShop 9 Readiness Check lists each of them with its file and line. It only reads, nothing is changed.

Get the free check

Prefer not to do the upgrade yourself? We upgrade stores to PrestaShop 9 for a fixed price. See the upgrade