Closed komackaj closed 6 years ago
The workaround doesn't work if raw data start with magick header for any format - original constructor calls ConstituteImage with a special path for RGB, RGBA, BGR and so on, while constructing from blob calls BlobToImage that tries to autodetect format
img = Image(Blob(b"\0\0\0\0\4\0\0\0" + 92 * b"\0"), Geometry(5, 5), 8, "RGBA")
img.size().height() * img.size().width()
25
img = Image(Blob(b"\0\0\0\0\7\0\0\0" + 92 * b"\0"), Geometry(5, 5), 8, "RGBA")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Magick: invalid file format version () reported by coders/xwd.c:284 (ReadXWDImage)
>>>
Relates to https://sourceforge.net/p/graphicsmagick/bugs/75/
Hi,
I've noticed that constructing an Image from array of raw pixels is broken in Python3 due to str/bytes differences between. This code works fine with python2 (due to autoconversion from str to char), but fails with python3 (unable to convert bytes to char)
ends with
There is a simple Py2/3 compatible workaround using Blob
@hhatto For discussion - as a future improvement: How should be used aforementioned constructor with StorageType.IntegerPixel? What data (char*) should be passed from Python? Will we support e.g. a tuple/list of integer / float and Boost's extract method according to StorageType? If not, should we make this constructor deprecated?