Skip to main content

BMP image handler for Python (to numpy ndarray or PIL) native C .pyd

Project description

BMP image handler for Python (to numpy ndarray or PIL) native C .pyd

How to use

from pybmp import bmp
import numpy as np
import matplotlib.pyplot as plt
# import matplotlib.image as mpimg
from scipy import misc
from PIL import Image

fig = plt.figure()
axis = [fig.add_subplot(211 + _) for _ in range(2)]
img = Image.open('../res/cs_checker_7x5_24.bmp') # R,G,B
# fake convert to ubytes img:R,G,B -> s:R,G,B,FF -> im:B,G,R,A -> bm:B,G,R,A
nda = np.array(img)
r, c, m = nda.shape
s = img.tostring('raw', 'RGBX') # append A as FF
im = Image.fromstring('RGBA', (c, r), s, 'raw', 'BGRA') # fake to B,G,R,A
bm = np.array(im) # fake to B,G,R,A
axis[0].imshow(nda)
bmp.BMP(bm, fn='/tmp/cs_checker_out_.bmp')
# plt.show()

License

MIT License

Project details


Release history Release notifications

This version

1.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pybmp, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pybmp-1.0.1.tar.gz (9.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page