Mailing List Archive

GUI and creating GIF
Hello,

I would like to
1) create a GIF file under Python by drawing lines, text, ... I have looked
at Tk which can create bitmaps and photoimage but their seem to be no
possibility to transform a canvas into a photoimage.
2) rotate some text on a canvas.

Does anyone has a tip to do it under Tk, wxWindows or any other GUI?

Thanks by advance
GUI and creating GIF [ In reply to ]
Frank.Derville wrote:
>
> Hello,
>
> I would like to
> 1) create a GIF file under Python by drawing lines, text, ... I have looked
> at Tk which can create bitmaps and photoimage but their seem to be no
> possibility to transform a canvas into a photoimage.
> 2) rotate some text on a canvas.
>
> Does anyone has a tip to do it under Tk, wxWindows or any other GUI?
>
> Thanks by advance

I recommend you look at gdmodule by Richard Jones. I have a
pre-compiled Win32 binary if you need it.

http://starship.python.net/~richard/gdmodule/

-Mike
GUI and creating GIF [ In reply to ]
I'd also like to use gdmodule but I can't understand the documentation
(I've emailed to ask Richard Jones for more docs). I'm new to Python.
Does anyone have any sample programs they can send?
Thanks in advance,
John Leach



Mike Steed wrote:
>
> Frank.Derville wrote:
> >
> > Hello,
> >
> > I would like to
> > 1) create a GIF file under Python by drawing lines, text, ... I have looked
> > at Tk which can create bitmaps and photoimage but their seem to be no
> > possibility to transform a canvas into a photoimage.
> > 2) rotate some text on a canvas.
> >
> > Does anyone has a tip to do it under Tk, wxWindows or any other GUI?
> >
> > Thanks by advance
>
> I recommend you look at gdmodule by Richard Jones. I have a
> pre-compiled Win32 binary if you need it.
>
> http://starship.python.net/~richard/gdmodule/
>
> -Mike
GUI and creating GIF [ In reply to ]
John Leach wrote:
>
> I'd also like to use gdmodule but I can't understand the documentation
> (I've emailed to ask Richard Jones for more docs). I'm new to Python.
> Does anyone have any sample programs they can send?

You might look at Richard's httpd logfile reporting tool (graph.py uses
gdmodule).

http://starship.python.net/~richard/httpd_log/

Also, below is a simple demo that used to be distributed with gdmodule,
although it doesn't appear to be on Richard's site anymore. I don't
have "demoin.gif", so you will have to tweak the code some....

-Mike
-----

#!/usr/local/bin/python -i
import gd
import sys

# our test output image
im_out=gd.image((128,128))
white = im_out.colorAllocate((255,255,255))
im_out.colorTransparent(white)

# input image
im_in=gd.image("demoin.gif")
im_in.copyResizedTo(im_out,(16,16),(0,0),(96,96))

red = im_out.colorAllocate((255,0,0))
green = im_out.colorAllocate((0,255,0))
blue = im_out.colorAllocate((0,0,255))

# test origin - switch to lower left type origin
im_out.origin((0,128),1,-1)
im_out.line((50,0),(128,50), red)
im_out.origin((0,0),1,1)

# rectangle
im_out.line((8,8), (120,8), green)
im_out.line((120,8), (120,120), green)
im_out.line((120,120), (8,120), green)
im_out.line((8,120), (8,8), green)

im_out.string(gd.gdFontLarge, (16,16), "hi", red)
im_out.stringUp(gd.gdFontSmall, (32,32), "hi", red)

im_out.arc((64,64), (30,10), 0, 360, blue)
im_out.arc((64,64), (20,20), 45, 135, blue)

im_out.fill((4,4), blue)

im_out.polygon(((32,0),(0,64),(64,64)),green)

# a brush
im_out.setBrush(gd.image(im_in,(8,8)))
im_out.setStyle((0,0,0,0,0,0,0,1))
im_out.line((128,0),(0,128),gd.gdStyledBrushed)

im_out.interlace(1)

im_out.writeGif("demoout.gif")
GUI and creating GIF [ In reply to ]
Frank.Derville writes:
>I would like to
>1) create a GIF file under Python by drawing lines, text, ... I have looked
>at Tk which can create bitmaps and photoimage but their seem to be no
>possibility to transform a canvas into a photoimage.
>2) rotate some text on a canvas.

The Python Imaging Library seems to be what you need; look at
http://www.pythonware.com/products/pil/ . PIL lets you create Image
objects which are bitmaps that you can draw on and manipulate in
various ways, and save Images in one of a large number of different
formats, GIF and JPEG being the most common ones. There's also some
connectivity with Tkinter, so you can display Images on a canvas. I'm
not sure if PIL's font code can handle rotation, though.

--
A.M. Kuchling http://starship.python.net/crew/amk/
Fast, fat computers breed slow, lazy programmers.
-- Robert Hummel
GUI and creating GIF [ In reply to ]
[.[. This message was both posted and mailed: see
the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <7g7u2k$fr0$1@wanadoo.fr>, Frank.Derville
<Frank.Derville@wanadoo.fr> wrote:

> I would like to
> 1) create a GIF file under Python by drawing lines, text, ... I have looked
> at Tk which can create bitmaps and photoimage but their seem to be no
> possibility to transform a canvas into a photoimage.
> 2) rotate some text on a canvas.

You can do this with PIL (Python Imaging Library), but it's a little
painful.

You can also try PIDDLE, which is still under development -- but it can
do this if you're brave. It's the piddlePIL backend that you'd want.
See: http://www.strout.net/python/piddle/ for more info.

Cheers,
-- Joe

--
,------------------------------------------------------------------.
| Joseph J. Strout Biocomputing -- The Salk Institute |
| joe@strout.net http://www.strout.net |
`------------------------------------------------------------------'
Check out the Mac Web Directory! http://www.strout.net/macweb.cgi
GUI and creating GIF [ In reply to ]
[Mike Steed]
>
> John Leach wrote:
> >
> > I'd also like to use gdmodule but I can't understand the documentation
> > (I've emailed to ask Richard Jones for more docs). I'm new to Python.
> > Does anyone have any sample programs they can send?
>
> You might look at Richard's httpd logfile reporting tool (graph.py uses
> gdmodule).
>
> http://starship.python.net/~richard/httpd_log/
>
> Also, below is a simple demo that used to be distributed with gdmodule,
> although it doesn't appear to be on Richard's site anymore. I don't
> have "demoin.gif", so you will have to tweak the code some....

I lost the code, docs and demo scripts about a couple of months ago. I'll
put this demo script back up on the web page.

"demoin.gif" comes with GD - but you could use any GIF image.

graph.py is not something I'd point anyone to as sample code :) ... I'd feel
much better pointing them to the PIL version which I wrote much more recently
with a better design.


Richard
GUI and creating GIF [ In reply to ]
Andrew M. Kuchling wrote:

> Fast, fat computers breed slow, lazy programmers.
> -- Robert Hummel

"Remember when computers were slow and applications were fast?"
-- Ted Kowalski

--
Garry Hodgson seven times down
garry@sage.att.com eight times up
Software Innovation Services
AT&T Labs - zen proverb