You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raiseValueError('Got a %d bytes buffer, needs at least %d.'
% (length, stride*height))
appears to generate the correct output without any error message. For this reason, it seems like the condition is superfluous or wrong.
The text was updated successfully, but these errors were encountered:
FriedrichFroebel
changed the title
Interoperability issue with pycairo for ImageSurface.create_for_data
Interoperability issue with pycairo for ImageSurface.create_for_data and numpy data
Jan 26, 2024
Instead of trying to find wrong data lengths and stride values, we should rely on Cairo. Removing the condition is not enough, as we want to raise an error if anything goes wrong. The "right" way to do this would be to detect when cairo_image_surface_create_for_data returns a pointer to a nil surface and raise a ValueError then.
I am currently trying to understand why my code works with pycairo, but fails for cairocffi.
Let's take the script at https://github.com/FriedrichFroebel/python-djvulibre/blob/b6c68a3496a244403488034b30c8de4b935b02b5/examples/djvu2png and call it with
djvu2png --foreground ../tests/images/test1.djvu out.png
. With a regular pycairo installation, everything works fine. But as soon as I replaceimport cairo
withimport cairocffi as cairo
, I get an error:Simply removing the offending lines from the cairocffi source code at
cairocffi/cairocffi/surfaces.py
Lines 725 to 727 in f1984d6
The text was updated successfully, but these errors were encountered: