PythonMagick-0.9.10 is incomplete, pyste is unmaintained
Posted: 2014-08-05T05:17:22-07:00
Hello!
I was very happy to find the PythonMagick bindings, which actually allow me to reliably load 16-bit images. Yay! Thanks guys!
The bindings are, however, incomplete, which I'm sure you know, given that the last patch was about adding the MagickCore::ColorspaceType enum. There are other enums missing, making several exposed functions useless. One example: missing MagickCore::ImageType enum makes using Image::type() to make a grayscale image quite hard (quantizeColorSpace() doesn't work). What is also missing is the Image.data attribute documented here. Combined with str/bytes inconsistencies in the Blob class, they make accessing raw pixel data quite hard. I spent two days trying to find a reliable way to move data into a numpy array, and the best I could get was
and back again with
I wanted to fix these deficiencies, especially when I saw how simple it was to write pyste wrappers, but found that it was difficult to obtain pyste. Neither gentoo nor arch provide it anymore, and boost docs say that it is unmaintained. Have you considered using a different code generator? Boost docs suggest pyplusplus.
I was very happy to find the PythonMagick bindings, which actually allow me to reliably load 16-bit images. Yay! Thanks guys!
The bindings are, however, incomplete, which I'm sure you know, given that the last patch was about adding the MagickCore::ColorspaceType enum. There are other enums missing, making several exposed functions useless. One example: missing MagickCore::ImageType enum makes using Image::type() to make a grayscale image quite hard (quantizeColorSpace() doesn't work). What is also missing is the Image.data attribute documented here. Combined with str/bytes inconsistencies in the Blob class, they make accessing raw pixel data quite hard. I spent two days trying to find a reliable way to move data into a numpy array, and the best I could get was
Code: Select all
image = PythonMagick.Image(filename)
blob = PythonMagick.Blob()
image.write(blob, 'RGB', 16)
rawdata = b64decode(blob.base64())
img = np.ndarray((image.rows(), image.columns(), 3),
dtype='uint16', buffer=rawdata)
Code: Select all
cmap = 'RGB'
blob = PythonMagick.Blob()
blob.base64(b64encode(bytes(array)).decode('ascii'))
image = PythonMagick.Image(blob, PythonMagick.Geometry(width, height), 16, cmap)