pythonimagepngpbm

I have a PNG image, and wondering how to efficiently convert it to PBM in python


Is there any simple way for converting PNG to PBM?

ocrad requires PBM image, not PNG.


Solution

  • Check out Pillow. According to the docs, it supports PBM, PGM, and PPM formats out of the box. The following code should get you started:

    from PIL import Image
    
    im = Image.open("myfile.png")
    im.save("myfile.pbm")