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

2.5k Views Asked by At

Is there any simple way for converting PNG to PBM?

ocrad requires PBM image, not PNG.

1

There are 1 best solutions below

4
MattDMo On BEST ANSWER

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")