473,409 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Python Imaging Library and PyGTK - color image path?

I have an image in the Python Image Library. I'm trying to get it into
PyGTK in color. Is there any way to do this cross-platform, preferably
without writing to anything to the disk?

PIL apparently can't write XPMs. GTK will only take XPMs, that I can see.
Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd
rather be able to ship over full color.

(Use case, in case it matters: I am trying to embed a graphic into a text
widget. This is going fine. Because I want the text widget to be able use
different size text, and no one image can look right with everything from
8pt to 40pt text (all reasonable possibilities), I load a large image in
from the disk and scale it down as needed; the images are designed to
scale well and later I can make multiple source images if that is
desirable. But I can't figure out how to get the scaled image into GTK.
This surprises me.)

If there's an easy Google search, it has eluded me.
Jul 19 '05 #1
3 2577
On Fri, 22 Apr 2005 22:43:13 -0400, Jeremy Bowers wrote:
(Use case, in case it matters: I am trying to embed a graphic into a text
widget. This is going fine. Because I want the text widget to be able use
different size text, and no one image can look right with everything from
8pt to 40pt text (all reasonable possibilities), I load a large image in
from the disk and scale it down as needed; the images are designed to
scale well and later I can make multiple source images if that is
desirable. But I can't figure out how to get the scaled image into GTK.
This surprises me.)


As usual, posting for help after poking around for a long while guarantees
you'll figure it out in the next few minutes. You need to create GDK
pixbufs, which can be resized and scaled and stuff.

There is definitely some room for confusion here with GTK Images, GDK
Images, GTK pixbufs, and GDK pixbufs....
Jul 19 '05 #2
Jeremy Bowers wrote:
I have an image in the Python Image Library. I'm trying to get it into
PyGTK in color. Is there any way to do this cross-platform, preferably
without writing to anything to the disk?

PIL apparently can't write XPMs. GTK will only take XPMs, that I can see.
Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd
rather be able to ship over full color.


the first two google hits for "PyGTK PIL" are

http://www.daa.com.au/pipermail/pygt...il/009988.html

which provides a StringIO-based solution, and

http://www.daa.com.au/pipermail/pygt...ry/004393.html

which discusses draw_rgb_image and friends, and says that "if you can convert
your PIL image to a pixel data string or buffer object, you could use them to
display the image". here's some code that seems to do exactly that:

http://www.mail-archive.com/py***@da.../msg07167.html

(but maybe this is some kind of stupid "a bitmap isn't a pixmap isn't an image"
thing? if so, I suggest getting a modern windowing system ;-)

</F>

Jul 19 '05 #3
On Sat, 23 Apr 2005 10:20:29 +0200, Fredrik Lundh wrote:
which discusses draw_rgb_image and friends, and says that "if you can
convert your PIL image to a pixel data string or buffer object, you could
use them to display the image". here's some code that seems to do exactly
that:

http://www.mail-archive.com/py***@da.../msg07167.html

(but maybe this is some kind of stupid "a bitmap isn't a pixmap isn't an
image" thing? if so, I suggest getting a modern windowing system ;-)


A varient; I was missing the gdk.pixbuf because I assumed that because
there was a gtk.pixbuf that I knew about, that I had all relevant data.
Were that the only pixbuf, that would be an atrocity. (Particularly odd
for GTK, the *Gimp* windowing toolkit.)

(It of course figures that was the google search; I think I tried
everything but that; "python imaging library" "pygtk" isn't anywhere near
as helpful, for instance.)
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
20
by: BJ MacNevin | last post by:
Hi all, I teach middle school and am currently trying to bring some computer science to the students. Our district has a wonderfully linked network throughout all our schools... done via MS...
1
by: Jeremy C. Reed | last post by:
Configuring gramps (genealogy software) says: checking Python bindings for gtk... ok checking Python bindings for GNOME... ok checking Python bindings for gconf... Traceback (most recent call...
6
by: Steve Holden | last post by:
Does anyone know the workaround for this error, encountered when trying to build PIL 1.1.4 from source under cygwin (Python 2.3.3)? running build_ext building '_imaging' extension gcc...
6
by: Fuzzyman | last post by:
I'll post this to the image-sig as well, but the audience is a bit wider here. I've just upgraded to Python 2.4. I've installed the free microsoft optimising compiler and hacked distutils to use...
54
by: seberino | last post by:
Many people I know ask why Python does slicing the way it does..... Can anyone /please/ give me a good defense/justification??? I'm referring to why mystring gives me elements 0, 1, 2 and 3...
2
by: peter.mosley | last post by:
A few weeks ago I asked for advice about which GUI toolkit I should learn, and receved several helpful answers. In the end I went with Tkinter. This was because a) it was already installed on the...
5
by: Prateek | last post by:
Hi. I'm creating a web-application using CherryPy 2.2.1. My application needs to process images (JPG/PNG files) to 1) create thumbnails (resize them) 2) overlay them on a custom background (a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.