Php libpng warning iccp known incorrect srgb profile

Php libpng warning iccp known incorrect srgb profile

Description: ------------ imagecreatefromstring is writing a warning message to stderr that can not be suppressed by '@' or captured by the error handler. It should emit a proper PHP warning instead. I have the following version of libPNG: php -i | grep -i libpng libPNG Version => 1.6.19+apng To run the test script, download the sample PNG image from here: http://imgbox.com/BzOXLiOr Note: libPNG 1.5.18 on PHP 5.6.17 for Windows does not have this problem. Test script: --------------- php -r '@var_dump(imagecreatefromstring(file_get_contents("1CCHOHSULGF78KW.png")));' Expected result: ---------------- resource(6) of type (gd) Actual result: -------------- libpng warning: iCCP: known incorrect sRGB profile resource(6) of type (gd)

Patches

Pull Requests

History

Thanks for your report! Hm. This is a libpng warning.I suppose they move this warning to a simple warning level. I will see if we can implement the warning only callback without introducing too much noises: png_structp png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn); only png_error is used now and generates php error.
PHP 7.0.8 x64 on Windows. Same problem. Please fix.
can reproduce on php 7.1.17 @ ubuntu 17.10 (aka i inconveniently encountered this bug)
can't be captured with ob_start() either, does anybody have a workaround?
this just sucks wehn you verify that some file is really a png and get spewed by this messages (and no fileinfo is useless given that many errors it makes over years) libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: Interlace handling should be turned on when using png_read_image libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: CRC error
Here is a workaround for the "libpng warning: Interlace handling should be turned on when using png_read_image" warnings emitted to stdout. $command = "mogrify -interlace none *.png"; exec($command); Call this prior to calling imagecreatefromstring.
amazing for how many years random shit don't get fixed and no i don't care who and where is resposnible
> amazing for how many years random shit don't get fixed and no i > don't care who and where is resposnible Thanks for your valuable open-source contribution.
$imgInfo = getimagesize($imageFile); $img_w = $imgInfo[0]; $img_h = $imgInfo[1]; switch ($imgInfo[2]) < case 1: $bgImg =imagecreatefromgif($imageFile); //gif break; case 2: $bgImg =imagecreatefromjpeg($imageFile); //jpg break; case 3: $bgImg = imagecreatefrompng($imageFile); //png break; default: die("不支持的图片文件类型"); exit; >$fontfile = ROOT_DIR.'/../../Resources/font/simhei.ttf'; $fontfile = ROOT_DIR.'/font/simhei.ttf'; if(file_exists($fontfile)) < echo $imageFile."\n\n"; >$text_color = imagecolorallocatealpha($bgImg,0,0,0,75); $pos_x = 30; $pos_y = $img_h - 20; imagettftext($bgImg, 12, 0, $pos_x, $pos_y, $text_color, $fontfile, '审核药师:'); $shenhe_img = imagecreatefrompng( ROOT_DIR.'/yaoshi/'.$shenhe ); $shenheImgInfo = getimagesize( ROOT_DIR.'/yaoshi/'.$shenhe ); $resize_h = 35; $resize_w = intval($shenheImgInfo[0]*$resize_h/$shenheImgInfo[1]); $pos_x = 110; $pos_y = $img_h-$resize_h-5; imagecopyresized($bgImg, $shenhe_img, $pos_x, $pos_y, 0, 0, $resize_w, $resize_h, $shenheImgInfo[0], $shenheImgInfo[1]);
The following pull request has been associated: Patch Name: Fix #71316: libpng warning from imagecreatefromstring On GitHub: https://github.com/php/php-src/pull/7615 Patch: https://github.com/php/php-src/pull/7615.patch 
Automatic comment on behalf of cmb69 Revision: https://github.com/php/php-src/commit/1919c4b44ddd9f056bd53c79c4b99c9e4ce97884 Log: Fix #71316: libpng warning from imagecreatefromstring

Источник

Читайте также:  Api telegram bot php примеры

[SOLVE] Magento 2 libpng warning: iCCP: known incorrect sRGB profile, Wrong file, file does not exist

Magento 2 provide a very helpful command to resize images on storefronts to save disk space as well as make load speed of your website faster.

php bin/magento catalog:images:resize

S ome times, the error message libpng warning: iCCP: known incorrect sRGB profile appears when you resize product images on your Magento 2 storefront as below

libpng warning iCCP known incorrect sRGB profile

Throughout this tutorial, you will learn what caused this error and how to fix it

Cause of the error

When checking images ICC profiles, Magento 2 did not find iCCP chunk in PNG image profile, thus the system automatically throws this error message and stop the image resize process

Solution

To fix this issue, we will use Linux command to remove iCCP chunk from the images.

Connect to your server using SSH as root user and use the following syntax to remove iCCP chunk from PNG Images on your website.

If your images files located in pub/media

find pub/media -type f -iname '*.png' -exec pngcrush -ow -rem allb -reduce <> \;

Next, re-run image resize command and the issue is fixed, you now can resize images normally

If you see the error: Wrong file => that means the files you want to resize do not exist in the folder. Recheck the image files in that folder or you can force Magento 2 to ingore this error and continue the process by editing vendor/magento/module-media-storage/Service/ImageResize.php file and put the following code in line 186

if ($this->mediaDirectory->isFile($originalImagePath) && filesize())

Now all the error should go away and you can process image resize normally

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagecreatefrompng() libpng warnings #2718

imagecreatefrompng() libpng warnings #2718

Comments

From the recent fix of PHP library (https://bugs.php.net/bug.php?id=71316), there is an error exception thrown from libpng warnings. This causes the application unable to generate pdf (refer to dompdf/dompdf/lib/Cpdf.php:5612).

Please advise how we can prevent this issue.

The text was updated successfully, but these errors were encountered:

I guess warnings should be suppressed using @?
$img = @imagecreatefrompng($file);

I guess warnings should be suppressed using @? $img = @imagecreatefrompng($file);

@andrespoder Thank you for providing more details. The error that I got is
imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile in /var/www/vhosts/cs.soas.com/httpdocs/vendor/dompdf/dompdf/lib/Cpdf.php:5612

I have the same problem (incorrect sRGB profile) on PHP 8.0.7.
Is it possible to suppres that warning as well?

From the PHP bug report the following image generates the «iCCP: known incorrect sRGB profile» warning: http://imgbox.com/BzOXLiOr

I see a few locations where we use imagecreatefrompng that would need suppression.

If there are other images that generate warnings from GD that can be shared we’ll test with those as well. PNG seems to be the common denominator for this particular issue but we don’t use suppression on any of the GD methods (except for in one instance). Not sure if there are similar issues with other image formats.

Источник

libpng warning: iCCP: known incorrect sRGB profile

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

To remove the invalid iCCP chunk from all of the PNG files in a folder (directory), you can use mogrify from ImageMagick:

This requires that your ImageMagick was built with libpng16. You can easily check it by running:

convert -list format | grep PNG 

If you’d like to find out which files need to be fixed instead of blindly processing all of them, you can run

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.

Binary Releases of ImageMagick are here

For Android Projects (Android Studio) navigate into res folder.

C:\\app\src\main\res\drawable-hdpi\mogrify *.png 

Solution 2

Use pngcrush to remove the incorrect sRGB profile from the png file:

pngcrush -ow -rem allb -reduce file.png 
  • -ow will overwrite the input file
  • -rem allb will remove all ancillary chunks except tRNS and gAMA
  • -reduce does lossless color-type or bit-depth reduction

In the console output you should see Removed the sRGB chunk , and possibly more messages about chunk removals. You will end up with a smaller, optimized PNG file. As the command will overwrite the original file, make sure to create a backup or use version control.

Solution 3

Solution

The incorrect profile could be fixed by:

  1. Opening the image with the incorrect profile using QPixmap::load
  2. Saving the image back to the disk (already with the correct profile) using QPixmap::save

Note: This solution uses the Qt Library.

Example

Here is a minimal example I have written in C++ in order to demonstrate how to implement the proposed solution:

QPixmap pixmap; pixmap.load("badProfileImage.png"); QFile file("goodProfileImage.png"); file.open(QIODevice::WriteOnly); pixmap.save(&file, "PNG"); 

The complete source code of a GUI application based on this example is available on GitHub.

UPDATE FROM 05.12.2019: The answer was and is still valid, however there was a bug in the GUI application I have shared on GitHub, causing the output image to be empty. I have just fixed it and apologise for the inconvenience!

Solution 4

You can also just fix this in photoshop.

  1. Open your .png file.
  2. File -> Save As and in the dialog that opens up uncheck «ICC Profile: sRGB IEC61966-2.1»
  3. Uncheck «As a Copy».
  4. Courageously save over your original .png.
  5. Move on with your life knowing that you’ve removed just that little bit of evil from the world.

Solution 5

To add to Glenn’s great answer, here’s what I did to find which files were faulty:

find . -name "*.png" -type f -print0 | xargs \ -0 pngcrush_1_8_8_w64.exe -n -q > pngError.txt 2>&1 

I used the find and xargs because pngcrush could not handle lots of arguments (which were returned by **/*.png ). The -print0 and -0 is required to handle file names containing spaces.

Then search in the output for these lines: iCCP: Not recognizing known sRGB profile that has been edited .

./Installer/Images/installer_background.png: Total length of data found in critical chunks = 11286 pngcrush: iCCP: Not recognizing known sRGB profile that has been edited 

And for each of those, run mogrify on it to fix them.

mogrify ./Installer/Images/installer_background.png 

Doing this prevents having a commit changing every single png file in the repository when only a few have actually been modified. Plus it has the advantage to show exactly which files were faulty.

I tested this on Windows with a Cygwin console and a zsh shell. Thanks again to Glenn who put most of the above, I’m just adding an answer as it’s usually easier to find than comments 🙂

Источник

Оцените статью