1

Is there any simple way for converting PNG to PBM?

ocrad requires PBM image, not PNG.

miken32
  • 42,008
  • 16
  • 111
  • 154
Mika Feiler
  • 474
  • 3
  • 17

1 Answers1

1

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")
MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • On my 1001pxd used as a router it works perfectly, although on OS X 10.9.5 `sudo easy_install PIL` returns: https://gist.github.com/ArchieT/ceceb64a43b5d268dde2 – Mika Feiler Nov 20 '14 at 18:36
  • @ArchieT install using `pip`. Also, the package name is `pillow`, not `PIL`. Pillow is a fork of PIL, massively and continuously updated. `PIL` is ancient. – MattDMo Nov 20 '14 at 18:37
  • `gietwenti:~ mf$ sudo pip install PIL --allow-external PIL Downloading/unpacking PIL Could not find any downloads that satisfy the requirement PIL Some insecure and unverifiable files were ignored (use --allow-unverified PIL to allow). Cleaning up... No distributions at all found for PIL Storing debug log for failure in /Users/mf/.pip/pip.logz` Installing pillow using pip theoretically worked, but I cannot import it. And installing pillow using easy_install: [my gist link above] – Mika Feiler Nov 20 '14 at 18:46
  • I've read the documentation from your link; `sudo easy_install Pillow` — worked. And they wrote to not to use pip as it doesn't support Python Eggs. Anyway, thanks for a great and fast answer! – Mika Feiler Nov 20 '14 at 18:55