Also return image dimensions when loading PNG
This commit is contained in:
parent
2b035739f8
commit
1faddeb402
@ -105,7 +105,7 @@ load_png_data(PyObject *self UNUSED, PyObject *args) {
|
||||
inflate_png_inner(&d, (const uint8_t*)data, sz);
|
||||
PyObject *ans = NULL;
|
||||
if (d.ok && !PyErr_Occurred()) {
|
||||
ans = PyBytes_FromStringAndSize((const char*)d.decompressed, d.sz);
|
||||
ans = Py_BuildValue("y#ii", d.decompressed, (int)d.sz, d.width, d.height);
|
||||
} else {
|
||||
if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, "Unknown error while reading PNG data");
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ class TestGraphics(BaseTest):
|
||||
# 1x1 transparent PNG
|
||||
png_data = standard_b64decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==')
|
||||
expected = b'\x00\xff\xff\x7f'
|
||||
self.ae(load_png_data(png_data), expected)
|
||||
self.ae(load_png_data(png_data), (expected, 1, 1))
|
||||
s, g, l, sl = load_helpers(self)
|
||||
sl(png_data, f=100, expecting_data=expected)
|
||||
# test error handling for loading bad png data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user