[Image-SIG] PIL and rendering images

John Angelmo john.angelmo@webgiro.com
Tue, 07 Aug 2001 14:29:42 +0200


Hi I'm a happy private PIL user
For a small homepage for my former highschool I'm using PIL/Python to 
generate jpeg backgrounds (Just haven't changed JPEG to PNG yet)

The code is fairly simple:
--- Code ---
#!/usr/local/bin/python

import os, sys
import Image, ImageDraw


#def fromhex(s):
#  s='#cbb99c'
#  return int(s,16)
#  fromhex(s[1:3], bla bla
#  int(s[1:3],16),int(s[3:5],16),int(s[5:7],16)

#def crtimg(self,infile,im):
s='#cbb99c'
t='#a89779'
infile= 'background'
print infile
im = Image.new("RGB",[10,10],(int(s[1:3],16),int(s[3:5],16),int(s[5:7],16)))

impix = ImageDraw.Draw(im)
impix.point((2,2),(int(t[1:3],16),int(t[3:5],16),int(t[5:7],16)))
impix.point((7,2),(int(t[1:3],16),int(t[3:5],16),int(t[5:7],16)))
impix.point((2,7),(int(t[1:3],16),int(t[3:5],16),int(t[5:7],16)))
impix.point((7,7),(int(t[1:3],16),int(t[3:5],16),int(t[5:7],16)))
del impix

im.save(infile, "JPEG")


--- End Code ---

the background looks OK first but if I soom in (about 1500%) I can see 
that the four dots have created small distortions in the image is there 
any way to fix this?

I also get a strange error when I use PIL:

WARNING: Python C API version mismatch for module _imaging:
   This Python has API version 1010, module _imaging has version 1007.


Kind Regards

John A


-- 
Webgiro AB
---------------------
+46-850640765 Phone
+46-850640701 Fax
+46-733864346 Cellular
RIPE handle: JA4953-RIPE