[ocrfeeder] Fix problem when converting Gdk.Pixbuf to Image



commit 93dd2243014feffe5b77720119054fc0994840b5
Author: Joaquim Rocha <me joaquimrocha com>
Date:   Mon Jul 7 22:43:20 2014 +0200

    Fix problem when converting Gdk.Pixbuf to Image
    
    The previously used method was no longer working as Pillow
    would complain that "buffer is not large enough" so instead
    of using the Image.frombuffer, it now uses Image.frombytes.

 src/ocrfeeder/util/graphics.py |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
---
diff --git a/src/ocrfeeder/util/graphics.py b/src/ocrfeeder/util/graphics.py
index c9ba8e8..c1a858a 100644
--- a/src/ocrfeeder/util/graphics.py
+++ b/src/ocrfeeder/util/graphics.py
@@ -55,11 +55,9 @@ def getBoundsFromStartEndPoints(start_point, end_point):
 def convertPixbufToImage(pixbuf):
     assert(pixbuf.get_colorspace() == GdkPixbuf.Colorspace.RGB)
     dimensions = pixbuf.get_width(), pixbuf.get_height()
-    stride = pixbuf.get_rowstride()
     pixels = pixbuf.get_pixels()
     mode = pixbuf.get_has_alpha() and "RGBA" or "RGB"
-    return Image.frombuffer(mode, dimensions, pixels,
-                            "raw", mode, stride, 1)
+    return Image.frombytes(mode, dimensions, pixels)
 
 def rgbaToInteger(rgba):
     r, g, b, a = rgba


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]