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:

A. Save every 10 minutes
         t = time.localtime(now_time)
         s = "a%4d%02d%02d_%02d%02d%02d.tif" % (   NOTE my comments below B.
             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. {I erroneously 
thought gif.save was some PIL method.)

Hmmm, maybe I needed to use jpeg?

As for fits formats, I see PIL shows FITS for identify only. Not sure what 
that means. Read but not write?


Gary Herron wrote:
> W. Watson wrote:
>> In what library would I find gif.save(path), where path is the name 
>> and path   of a file, and the method would produce a file in a gif 
>> format?
>>
>> Is there a fits.save(path) somewhere? fits is commonly used in 
>> astronomical work.
>>   
> You may want to install PIL (the Python Image Library) for this:
> 
>  http://www.pythonware.com/products/pil/

-- 
                          Wayne Watson (Nevada City, CA)

                        Web Page: <speckledwithStars.net>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to