How to solve these libpng errors in pygame?

1

These errors are shown when I close the game:

libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: cHRM chunk does not match sRGB

These errors happen because I'm using this:

pygame.display.set_icon(pygame.image.load("imagens/truco.png"))

How to solve this?

    
asked by anonymous 04.11.2017 / 13:36

2 answers

3

No errors, are "warnings" (warning), and maybe the problem is with the strong (ICC profile) image and probably does not affect your application, you can even ignore these warnings if you wish, that is not a problem in your code.

What you can easily solve by using a drawing program to correct "image" with problem, such as GIMP or Photoshop.

There is an online solution like this: link - which in addition to probably solving these "warnings" will still reduce the size of the images making your program more take it in different directions.

There is also the link (download link ) that is able to remove the invalid color profiles, once installed using this command:

pngcrush -ow -rem allb -reduce file.png
    
04.11.2017 / 15:39
2

This is a warning issued by libpng . It means that the PNG image file you are using has chunks iCCP invalid .

To remove invalid chunks from a PNG image, you can use the convert of the ImageMagick library by passing the -strip at the command line:

$ convert icone.png -strip icone_ok.png

Assuming you have an image file, in PNG format, with dimensions of 400x400 , called icone.png :

Hereisaprogramthatcanloadtheaboveimageusingthepygame.image.load()functionandthenuseitasthewindowiconcreatedbymeansofthepygame.display.set_icon()functionwithoutanykindoferrororwarning:

importsysimportpygamepygame.init()icon=pygame.image.load('icone.png')screen=pygame.display.set_mode((500,500))pygame.display.set_caption('FooBar')pygame.display.set_icon(icon)screen.blit(icon,(50,50))clk=pygame.time.Clock()running=True;whilerunning:foreventinpygame.event.get():ifevent.type==pygame.QUIT:running=False;pygame.display.update()clk.tick(25);pygame.quit()sys.exit()

ExamplebeingtestedonaworkspaceLinux/GNOME:

    
04.11.2017 / 15:27