Type
bug
Priority
major
Status
new
Component
Version
pil-1.1.7
Watchers
2

Problem opening sunraster files 8bpp gray

Matthieu Walraet avatarMatthieu Walraet created an issue

I've an error opening a gray sunrasterfile, with this code:

from PIL import Image
graysun = Image.open("grey.ras")
d = graysun.load()

I get:

  File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 148, in load
 self.mode, self.size, a[1], a[2]
IndexError: tuple index out of range

I found a way to patch "SunImagePlugin.py" to correct this issue, line 77 I have replaced:

self.tile = [("raw", (0,0)+self.size, offset, (rawmode, stride))]

by:

self.tile = [("raw", (0,0)+self.size, offset, (rawmode, stride, 1))]

The third item of tupple correspond to orientation.

According to http://www.pythonware.com/library/pil/handbook/decoder.htm << When used in a tile descriptor, the parameter field should look like: (raw mode, stride, orientation) (...) orientation: Whether the first line in the image is the top line on the screen (1), or the bottom line (-1). If omitted, the orientation defaults to 1. >>

Seems like the orientation parameter can't be omitted. I'm not sure if problem should be fixed in SunImagePlugin.py to add orientation as I've done, or in ImageFile.py to accept missing orientation.

Regards, Matthieu

Comments (0)

  1. Log in to comment »
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.