Libpng warning when generating image thumbs

Hi,

I feel like my question is more PHP than Kirby related, but I will ask anyway. After migrating a website to PHP 8, I realized some images are not processed (resized, converted etc.). It worked properly before, I mean while the site was running on PHP 7.

Let’s say I write:

<img src=”<?= $someImage->resize(300)->url() ?>” alt=””>

The first time the page is loaded, I get an exception:

imagecreatefromstring(): gd-png: libpng warning: iCCP: known incorrect sRGB profile

Problem is it does not crash with all images, just some of them. I suspect it is somehow connected to the software the image was exported from / edited in. Although I have no idea what specific photo editing program could be causing this.

Even though it does not break the whole website, it is really unpleasant. Original image files are loaded instead of resized ones, conversion to webp does not happen etc.

So here is my question: is it possible to suppress this exception and let Kirby create the image? And if so, is it even advisable? I cannot foresee possible implications it could have. Or is there any other solution (I know the best one would be to upload “correct” image files, but I often have no control over what client uploads to the site)?

Any advice would be highly appreciated. :slight_smile:

Those images seem to have a bad sRGB profile.

There are some ways to fix it here c++ - libpng warning: iCCP: known incorrect sRGB profile - Stack Overflow