pygtk2 and its numpy dependency

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

 



pygtk2 implements a function called gtk.gdk.get_pixels_array(), which
returns the pixel contents of a GDK pixbuf as a numpy array.  Fine and
dandy, but this means it links against numpy (7 megs) which is itself
linked against atlas (12 megs).  Kind of a lot for a single function,
especially on a live image.

Especially for a function that's basically unused!  gnome-applet-music
uses it to implement a poor-man's Porter-Duff blend, and that's the only
caller currently packaged in Fedora, at least according to package deps.
I have a patch (attached) that fixes that [1], which means we could
compile our pygtk2 without numpy support and not break anything in
Fedora proper.

However, google codesearch does turn up what look like a few other users
of that function, some of which we may actually want to ship someday.
So we've got options:

a) remove the explicit Requires: numpy from pygtk2, require apps that
actually want this function to Require it themselves

b) fake the numpy data type ABI in pygtk2 itself by cult-and-pasting it
from numpy

c) declare that get_pixels_array() just doesn't work in Fedora
(historically true, back in like FC3)

d) leave things as they are

I lean towards a).  I think b) is icky but doable, since that ABI is
effectively unbreakable anyway (inherited from the older python-numeric
module).  The other two are way lame.

Thoughts?

[1] - Readers are invited to count the wtf's in the code being replaced,
as well as in its callers.  Don't treat it as a drinking game though.

- ajax
diff -up ./music-applet-2.5.1/src/musicapplet/applet.py.jx ./music-applet-2.5.1/src/musicapplet/applet.py
--- ./music-applet-2.5.1/src/musicapplet/applet.py.jx	2009-08-10 15:03:29.000000000 -0400
+++ ./music-applet-2.5.1/src/musicapplet/applet.py	2009-08-10 15:03:36.000000000 -0400
@@ -831,22 +831,11 @@ class Rating (gtk.EventBox):
 
 
     def create_colorized_pixbuf (self, stock_pixbuf, color):
-        pixbuf = stock_pixbuf.copy ()
-        red_scale = color.red / 65535.0
-        green_scale = color.green / 65535.0
-        blue_scale = color.blue / 65535.0
-        for row in pixbuf.get_pixels_array ():
-            for pixel in row:
-                # Yay API changes!
-                if str (type (pixel[0])) == "<type 'array'>":
-                    pixel[0][0] *= red_scale
-                    pixel[1][0] *= green_scale
-                    pixel[2][0] *= blue_scale
-                else:
-                    pixel[0] *= red_scale
-                    pixel[1] *= green_scale
-                    pixel[2] *= blue_scale
-        return pixbuf
+	pixbuf = stock_pixbuf.composite_color_simple(stock_pixbuf.get_width(),
+						     stock_pixbuf.get_height(),
+						     gtk.gdk.INTERP_NEAREST,
+						     255, 1, color, color)
+	return pixbuf
 
 
 

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux