Astronomy Fits format and

W. Watson wolf_tracks at
Sat Mar 29 01:38:08 CET 2008

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")  <============ save image
         if self.trigger_mode:

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",
             path = asksaveasfilename(defaultextension=".gif",
                                      title="Save as GIF",
         if not path:
         gif = self.current_image.convert("RGB") <===========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 in the first. {I erroneously 
thought 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, where path is the name 
>> and path   of a file, and the method would produce a file in a gif 
>> format?
>> Is there a somewhere? fits is commonly used in 
>> astronomical work.
> You may want to install PIL (the Python Image Library) for this:

                          Wayne Watson (Nevada City, CA)

                        Web Page: <>

More information about the Python-list mailing list