PIL and PSDraw

S

Sybren Stuvel

Hi there,

I'm experimenting with PIL to create a PostScript file. The end result
should be an EPS file with a couple of bar graphs.

At this moment, I have a very simple piece of code:

ps = PIL.PSDraw.PSDraw(file('demo.ps', 'w'))
ps.begin_document()
ps.rectangle((0, 0, 650, 150))
ps.end_document()

Unfortunately, when looking at 'demo.ps' using ghostview, I see an
empty page. This feeling of 'emptyness' is augmented by 'ps2epsi',
which tells me:

$ ps2epsi demo.ps
blank page!!

Can anyone tell me what I'm doing wrong? I've just started to use PIL,
so if there is something better to create EPS files, please let me
know!

Sybren

The contents of demo.ps:
======================================================================
%!PS-Adobe-3.0
save
/showpage { } def
%%EndComments
%%BeginDocument
/S { show } bind def
/P { moveto show } bind def
/M { moveto } bind def
/X { 0 rmoveto } bind def
/Y { 0 exch rmoveto } bind def
/E { findfont
dup maxlength dict begin
{
1 index /FID ne { def } { pop pop } ifelse
} forall
/Encoding exch def
dup /FontName exch def
currentdict end definefont pop
} bind def
/F { findfont exch scalefont dup setfont
[ exch /setfont cvx ] cvx bind def
} bind def
/Vm { moveto } bind def
/Va { newpath arcn stroke } bind def
/Vl { moveto lineto stroke } bind def
/Vc { newpath 0 360 arc closepath } bind def
/Vr { exch dup 0 rlineto
exch dup neg 0 exch rlineto
exch neg 0 rlineto
0 exch rlineto
100 div setgray fill 0 setgray } bind def
/Tm matrix def
/Ve { Tm currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
Tm setmatrix
} bind def
/Vf { currentgray exch setgray fill setgray } bind def
%%EndProlog
0 0 M 650 150 0 Vr
%%EndDocument
restore showpage
%%End
======================================================================
 
K

Kjell Magne Fauske

S

Sybren Stuvel

Kjell Magne Fauske enlightened us with:
PIL is, as far as i know,primarily a tool for creating and
manipulating raster graphics.

I was afraid of that.
If you want to create eps vector graphics with Python I recommend
PyX:

That looks exactly what I was looking for. Thanks a lot!

Sybren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top