[Image-SIG] Default Structure of a 640x480 PIL BMP File?

Fredrik Lundh fredrik at pythonware.com
Sat Apr 4 03:29:10 CEST 2009

On Sat, Apr 4, 2009 at 2:56 AM, Wayne Watson
<sierra_mtnview at sbcglobal.net> wrote:
> I'm definitely well beyond my student days.
> Two months ago I took it upon myself to add new features to a 2000+ line
> program,  authored by someone else, that use a special video camera and
> hardware to detect bright meteors, and produce video images, b/w. My prior
> experience with Python Win was limited to maybe a month of non-GUI work. No
> Tkinter or PIL. I've gotten a fair dose of Tkinter with dialogs and menus.
> A few days ago I began looking at analytic features that I might want to add
> using the video images/frames.  My first question was what sort of video
> format is used? The answer seems to be a 640/480 b/w 8-bit pixel. That's it.
> No headers or anything else. Although the image, date/time, meteor track
> data are written to files, the files are not anything anyone else uses.
> The user can write individual frames in jpg and tiff. I began think of
> adding bmp; however, I was curious how bmp worked, and whether I had control
> over the bit depth. I understand the jpb and tiff have no headers--I think.
> As I understand, it bmp has several types of blocks before the image, dib,
> header, palette, I think.  If I'm going to have to provide them, I have yet
> to figure that out. At this point, I'm mostly curious about them.

That still doesn't make much sense - TIFF and JPEG definitely have
headers that identify the contents of the files, and surely the point
of using PIL for this would be to let PIL handle the BMP writing for
you, not use the PIL handbook to figure out how to generate your own
BMP files?  All you have to do is to store the pixel data in a PIL
Image object, and then call the save method:

    # load the image into a PIL Image object
    im = Image.open(filename)
    # or Image.fromstring or frombuffer or new/putdata or...

    # save the image to disk, as a BMP file

But we're still missing way too much information to know how to best
help you sort this one out.  From where are you getting the video
frames, and what format does the frames have?  Is it just a
640x408=307200 byte file on disk, with no headers or anything?  Or do
you have the data in a memory buffer?   What language is the program
written in?  If Python, what GUI toolkit are you using to display the


More information about the Image-SIG mailing list