How do I disable the libpng warning? (python, pygame)

后端 未结 1 1913
鱼传尺愫
鱼传尺愫 2021-02-19 21:54

When I run my program it gives me the following warning:

libpng warning: iCCP: known incorrect sRGB profile

I know why this is caused, the

相关标签:
1条回答
  • 2021-02-19 22:11

    well, you can ignore the warning. I am using ImageMagick for image resizing, and for some png file, the following code will throw exception: iCCP: known incorrect sRGB profile `' @ warning/png.c/MagickPNGWarningHandler/1830

    Blob ablob(cont.data(), cont.size()); // cont is the png file content.
    Image image;
    image.read(ablob);
    image.resize( Geometry(100, 100) );
    

    As it says, it's just a warning, you can put the image.read(ablob) in a try{}catch{} block, and ignore the exception. The object image now contains the integrated png data, and can be manipulated correctly.

    0 讨论(0)
提交回复
热议问题