Opening colour BMPs with PIL

Discussion in 'Python' started by Craig, Dec 4, 2006.

  1. Craig

    Craig Guest

    Hi there,

    I'm trying to open colour BMPs using PIL and I'm getting the following
    errors.

    Opening a 16 colour BMP I get:

    >>> im = Image.open("image.bmp")


    Traceback (most recent call last):
    File "<pyshell#3>", line 1, in <module>
    im = Image.open("lightbulb2.bmp")
    File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1901, in open
    return factory(fp, filename)
    File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 82, in
    __init__
    self._open()
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 164,
    in _open
    self._bitmap(offset=offset)
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 120,
    in _bitmap
    raise IOError("Unsupported BMP compression (%d)" % compression)
    IOError: Unsupported BMP compression (2)
    >>>



    Opening a 256 colour BMP I get:

    >>> im = Image.open("image.bmp")


    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in <module>
    im = Image.open("image.bmp")
    File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1901, in open
    return factory(fp, filename)
    File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 82, in
    __init__
    self._open()
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 164,
    in _open
    self._bitmap(offset=offset)
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 120,
    in _bitmap
    raise IOError("Unsupported BMP compression (%d)" % compression)
    IOError: Unsupported BMP compression (1)
    >>>



    Opening a 24 bit colour BMP I get:

    >>> im = Image.open("image.bmp")


    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in <module>
    im = Image.open("image.bmp")
    File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1901, in open
    return factory(fp, filename)
    File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 82, in
    __init__
    self._open()
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 164,
    in _open
    self._bitmap(offset=offset)
    File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 96,
    in _bitmap
    raise IOError("Unsupported BMP header type (%d)" % len(s))
    IOError: Unsupported BMP header type (108)
    >>>



    I am using Windows XP with Python 2.5. I can open monochrome BMPs fine
    but I don't want that. If you could help that would be greatly
    appreciated. Thanks and good luck.


    Craig
     
    Craig, Dec 4, 2006
    #1
    1. Advertising

  2. Craig wrote:

    > I'm trying to open colour BMPs using PIL and I'm getting the following
    > errors.


    what program did you use to produce those BMP files? can you prepare
    reasonably small samples using the same program and post them somewhere?

    </F>
     
    Fredrik Lundh, Dec 5, 2006
    #2
    1. Advertising

  3. Craig

    Craig Guest

    Fredrik Lundh wrote:

    > Craig wrote:
    >
    > > I'm trying to open colour BMPs using PIL and I'm getting the following
    > > errors.

    >
    > what program did you use to produce those BMP files? can you prepare
    > reasonably small samples using the same program and post them somewhere?
    >
    > </F>


    Thanks for the reply. I'm using Microsoft Paint to create the files so
    that's most likely the problem (surprise, surprise). I found that by
    using GIMP to create them has no problems with opening BMP images.
    I'll just keep using GIMP instead.
     
    Craig, Dec 6, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nhwk

    Writing BMPs

    Nhwk, Aug 26, 2003, in forum: C++
    Replies:
    4
    Views:
    493
    Peter van Merkerk
    Aug 26, 2003
  2. Terry Hancock

    Re: [PIL]: Question On Changing Colour

    Terry Hancock, Oct 12, 2005, in forum: Python
    Replies:
    3
    Views:
    669
    Scott David Daniels
    Oct 14, 2005
  3. Johny

    PIL and font colour

    Johny, Apr 24, 2007, in forum: Python
    Replies:
    0
    Views:
    263
    Johny
    Apr 24, 2007
  4. Johny

    PIL and font colour

    Johny, Apr 24, 2007, in forum: Python
    Replies:
    3
    Views:
    389
    Steve Holden
    Apr 26, 2007
  5. jodleren
    Replies:
    2
    Views:
    208
    Thomas 'PointedEars' Lahn
    Jan 12, 2008
Loading...

Share This Page