-1

The warning mentioned in the title keeps appearing while trying to display an image in OpenCV2 with python 2.7.

How to get rid of this kind of warning?

| improve this question | |
2

You can use pngcrush to remove the sBIT chunk:

pngcrush -rem sbit source.png fixed.png

In fact you don't even need to say -rem sbit because pngcrush will detect the fact that the sBIT chunk is invalid and will silently remove it for you.

You could also try ImageMagick or GraphicsMagick

magick source.png fixed.png
gm convert source.png fixed.png

I believe that neither ImageMagick nor GraphicMagick supports writing the sBIT chunk, so it'll be removed whether or not it is valid.

| improve this answer | |
  • What are valid lengths of PNG's sBIT chunk (length as in amount of bytes)? I think removing the chunk could be problematic. It could probably be repaired in a hex editor or something. – Rublacava 10 mins ago
1

Try running your image through pngcheck to see if it is corrupt, or what is wrong with it. Then fix the source wherever you got it from.

| improve this answer | |
1

sBIT refers to Significant bits. A chunk is used to convey information related to a particular image.

In your case, there is mostly an issue with the depth of the image you are using. The sBIT changes for every type of image. By type of image I mean: grayscale, RGB, grayscale with alpha, etc..

Visit THIS PAGE and scroll down to sBIT Significant bits section to learn more.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.