cancel
Showing results for 
Search instead for 
Did you mean: 

libpng warning: iCCP: known incorrect sRGB profile

SOLVED

libpng warning: iCCP: known incorrect sRGB profile

Hello guys,

 

I'm getting below error message when running "bin/magento catalog:image:resize"

 

libpng warning: iCCP: known incorrect sRGB profile

 

there are 530k catalog images and error occurs after resize 249k images.

How an I fix this issue?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: libpng warning: iCCP: known incorrect sRGB profile

Hello @chathuramk ,

 

Libpng-1.6 is more stringent about checking ICC profiles than previous versions. You can ignore the warning. To get rid of it, remove the iCCP chunk from the PNG image.

 

Some applications treat warnings as errors; if you are using such an application you do have to remove the chunk. You can do that with any of a variety of PNG editors such as ImageMagick's convert in.png out.png.

 

To remove the invalid iCCP chunk from all of the PNG files in a folder (directory), you can use ImageMagick's mogrify *.png, provided that your ImageMagick was built with libpng16 (run convert -list format | grep PNG to be sure of that).

 

If you'd like to find out which files need to be fixed instead of blindly processing all of them, you can run my pngcrush -n -q *.png where the "-n" means don't rewrite the files and "-q" means suppress most of the output except for warnings. Sorry, there's no option yet in pngcrush to suppress everything but the warnings.

 

or 

Run below command 

Use find . -type f -name '*.png' -execute mogrify \{\} \; to recursively modify .png files in current directory. 
 
--
If my answer is useful, please Accept as Solution & give Kudos

View solution in original post

3 REPLIES 3

Re: libpng warning: iCCP: known incorrect sRGB profile

Hello @chathuramk 

 

I have seen the same issue thread on the forum itself, here i am sharing the link for the same - https://community.magento.com/t5/Magento-2-x-Version-Upgrades/after-upgrade-from-2-1-6-to-2-1-7-prod...

 

Kindly check it might helps you for the same

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: libpng warning: iCCP: known incorrect sRGB profile

Hello @chathuramk ,

 

Libpng-1.6 is more stringent about checking ICC profiles than previous versions. You can ignore the warning. To get rid of it, remove the iCCP chunk from the PNG image.

 

Some applications treat warnings as errors; if you are using such an application you do have to remove the chunk. You can do that with any of a variety of PNG editors such as ImageMagick's convert in.png out.png.

 

To remove the invalid iCCP chunk from all of the PNG files in a folder (directory), you can use ImageMagick's mogrify *.png, provided that your ImageMagick was built with libpng16 (run convert -list format | grep PNG to be sure of that).

 

If you'd like to find out which files need to be fixed instead of blindly processing all of them, you can run my pngcrush -n -q *.png where the "-n" means don't rewrite the files and "-q" means suppress most of the output except for warnings. Sorry, there's no option yet in pngcrush to suppress everything but the warnings.

 

or 

Run below command 

Use find . -type f -name '*.png' -execute mogrify \{\} \; to recursively modify .png files in current directory. 
 
--
If my answer is useful, please Accept as Solution & give Kudos

Re: libpng warning: iCCP: known incorrect sRGB profile

I know this is marked as solved, but there is way to programmatically resolve this
One worked for me:

- Pick any solution which can support calling external util `pgncrush' - i decided to roll composer package  flynsarmy/image-optimizer (based on ps/image-optimizer but with php8+ support)
- try-catch the error
- Initiate and run optimizer as followed


$optimizerFactory = new \ImageOptimizer\OptimizerFactory( [ 'custom_optimizers' => [ 'pngcrush_iccp_removal' => [ 'command' => 'pngcrush', 'args' => ['-ow', '-rem', 'allb', '-reduce'], ], ], ] ); try { $optimizerFactory->get('pngcrush_iccp_removal')->optimize($this->_fileName); $this->_imageHandler = call_user_func( $this->_getCallback('create', null, sprintf('Unsupported image format. File: %s', $this->_fileName)), $this->_fileName ); } catch (\ImageOptimizer\Exception\CommandNotFound $e) { $this->logger->notice('Optimizer `pngcrush` not available'); } catch (\ImageOptimizer\Exception\Exception $e) { $this->logger->notice('Optimizer `pngcrush` failed: ' . $e->getMessage()); }

(as called method `$this->_callback` and property `$this->_fileName`, the modifications are over the core Gd2 image adapter)