[Python-de] PIL-PSDraw-Probleme mit gsize und PDF
doch at ba-horb.de
doch at ba-horb.de
Don Okt 21 12:20:19 CEST 2004
Hallo zusammen,
ich habe ein kleines Skript um ein bisschen PIL zu testen. Ich bekomme
derzeit bei einem TIF-Bild ein fehlerhaftes PS-File mit einem Eintrag
gsize, das der Distiller bei der PDF-Erzeugung mit folgendem Error-Logfile
quittiert:
%%[ Error: undefined; OffendingCommand: gsize ]%%
Stack:
-save-
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
Ich kann diesen gsize-Befehl aus der PS-Datei rausnehmen, dann kann ich
auch ein PDF erzeugen. Aber irgendwas ist da ja faul. Wer weiß etwas über
den gsize-Befehl, was der macht, bzw. Konflikte damit?
Gruß
Christof
Hier das Skript (aus dem Beispiel vom Pythonware Handbook für PIL):
------schnipp----------
def PILImport(self):
from PIL import Image, ImageFile
import os, sys
from PIL import PSDraw
im = Image.open("c:/test1.eps")
sw = im.size[0]
sl = im.size[1]
md = im.mode
fm = im.format
title = "test"
box = (1*72, 2*72, 7*72, 10*72) # in points
pr = open("new.ps", "w")
ps = PSDraw.PSDraw(pr) # default is sys.stdout
ps.begin_document(title)
# draw the image (75 dpi)
ps.image(box, im, 75)
ps.rectangle(box)
# draw centered title
ps.setfont("Times", 36)
# w, h, b =
ps.text((4*72-36/2, 1*72-36), title)
ps.end_document()
# return ps
return 'Das Bild ist %s Pixel breit und %s Pixel hoch, liegt im
%s-Modus vor und ist im Format %s gespeichert.' % (sw, sl, md, fm)
--------schnapp------------------