ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
[Image-SIG] PIL: Can't open saved BMP image
by Sheila King other posts by this author
Aug 4 2003 6:06PM messages near this date
Re: [Image-SIG] "classical" image processing | Re: [Image-SIG] PIL: Can't open saved BMP image
I am just trying out PIL since last night, and only doing the most basic of
stuff.

I had gotten down how to create a new image and draw lines and pixels and
save as a BMP image last night, and then I would be able to open them in
Ulead's PhotoImpact or other image viewing software if I so desired.

Well, today I ran a script and the first time it saved the image just fine
for me, but on repeated runs the script completes without error, but when I
try to open the saved image in anything (including PIL), I get an error
that it cannot open the image.

Here is the script that is creating the image (on Win32 Python 2.2.2 under
Windows 2000):

-------(begin creation script)----------------
import Image, ImageDraw

graph = Image.new("RGB", (660,350), "white")
drw = ImageDraw.Draw(graph)
drw.setink("black")

## draw axes
## horizontal axis
for y in range(300,305):
    drw.line((50,y,650,y))
graph.show()
## vertical axis
for x in range(45,50):
    drw.line((x,0,x,305))
graph.show()

graph.save(open("graphout2.bmp", "w"))

--------(end creation script)-----------------

BTW, the "show" commands work just fine and open up BMP images for me in
Ulead PhotoImpact. 

However, the saved graphic, "graphout2.bmp" cannot be opened.

Here is a traceout from trying to open in PIL.

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
> >> import Image
> >> im = Image.open("graphout2.bmp")
Traceback (most recent call last):
  File "<pyshell#1> ", line 1, in ?
    im = Image.open("graphout2.bmp")
  File "E:\PYTHON22\Lib\site-packages\PIL\Image.py", line 1556, in open
    return factory(fp, filename)
  File "E:\PYTHON22\Lib\site-packages\PIL\ImageFile.py", line 78, in
__init__
    self._open()
  File "E:\PYTHON22\Lib\site-packages\PIL\BmpImagePlugin.py", line 164, in
_open
    self._bitmap(offset=offset)
  File "E:\PYTHON22\Lib\site-packages\PIL\BmpImagePlugin.py", line 96, in
_bitmap
    raise IOError("Unsupported BMP header type (%d)" % len(s))
IOError: Unsupported BMP header type (10240)
> >> 

If I'm doing something stupid here, I'd certainly appreciate someone giving
me a kick in the head and setting me straight.

Thanks,

-- 
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org



_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Sheila King
Sheila King

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved