I'm pretty new to Python and libraries. I'm actually trying to modify
some code someone else wrote. There are two ways images are saved. One
is for the user to select a "Save as GIF" menu item, or save as tiff, or
others. The other way is that the user wants a collected image from a
camera saved every, say, 10 minutes. The "save" process is different for
some reason. Here are the two code segments involved (NOTE my comments
and questions below B.):
A. Save every 10 minutes
t = time.localtime(now_time)
s = "a%4d%02d%02d_%02d%02d%02d.tif" % (
t.tm_year, t.tm_mon, t.tm_mday,
t.tm_hour, t.tm_min, t.tm_sec )
s = os.path.join("Exposures",s) <========== auto-exposures
if not os.path.exists("Exposures"):
os.mkdir("Exposures")
self.current_image.save(s) <============ save image
if self.trigger_mode:
self.Trigger()
self.CheckEvent()
contrast this with where the user specifically wants the image he sees
saved as a gif:
B. From menu option
def SaveGIF(self):
if self.current_path:
default_path = splitext(basename(self.current_path))[0] +
".gif"
path = asksaveasfilename(defaultextension=".gif",
title="Save as GIF",
initialfile=default_path,
filetypes=GIF_FILE_TYPES)
else:
path = asksaveasfilename(defaultextension=".gif",
title="Save as GIF",
filetypes=GIF_FILE_TYPES)
if not path:
return
gif = self.current_image.convert("RGB")
gif.save(path) <===========Save as gif.
The programmer told me if I change the tif in A. to gif, jpg or
whatever, it would work. Instead I get a file the of zero length when I
use jpg. Can anyone explain why this wouldn't work? I see that
current_image.convert is involved in one place and current_image.save in
the first. What module owns these "current" methods?
Hmmm, maybe I needed to use jpeg?
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
"The only laws of matter are those which our minds must
fabricate, and the only laws of mind are fabricated
for it by matter." -- James Clerk Maxwell
Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor