PIL and saved images coming out all garbled?

G. Willoughby sab at freeuk.com
Tue Mar 26 15:59:48 EST 2002


Hi,
i have a problem with saved images coming out all garbled when i use PIL.
this is the code i am using:

[snip]
self.currentImage=Image.open("mapper/thumbnail.jpg")
self.currentPhotoImage=ImageTk.PhotoImage(self.currentImage)
self.mapImage=self.thumbnail.create_image(0, 0,
image=self.currentPhotoImage, anchor=NW)
[/snip]

[snip]
def saveImage(self):
 try:
  if self.currentImage:
   savePath=tkFileDialog.asksaveasfile(title="Save", filetypes=[("Jpeg
File", ".jpg")], defaultextension=".jpg", initialdir="C:\windows\desktop")
   if savePath:
    Image.open("mapper/thumbnail.jpg").save(savePath, "JPEG", quality=100)
 except AttributeError:
  pass
[/snip]

and every time i use the save function the image is all multicoloured and
garbled. is this because i have already opened it with the first section of
code? is there a nicer/proper way?

Thanks,

G. Willoughby





More information about the Python-list mailing list