Skip to content

Commit

Permalink
Merge b634239 into fbb92e9
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 18, 2017
2 parents fbb92e9 + b634239 commit 3b499c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
19 changes: 3 additions & 16 deletions PIL/GdImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@

from . import ImageFile, ImagePalette
from ._binary import i16be as i16
from ._util import isPath

__version__ = "0.1"

try:
import builtins
except ImportError:
import __builtin__
builtins = __builtin__


##
# Image plugin for the GD uncompressed format. Note that this format
Expand All @@ -53,12 +46,12 @@ def _open(self):
s = self.fp.read(775)

self.mode = "L" # FIXME: "P"
self.size = i16(s[0:2]), i16(s[2:4])
self.size = i16(s[2:4]), i16(s[4:6])

# transparency index
tindex = i16(s[5:7])
if tindex < 256:
self.info["transparent"] = tindex
self.info["transparency"] = tindex

self.palette = ImagePalette.raw("RGB", s[7:])

Expand All @@ -78,13 +71,7 @@ def open(fp, mode="r"):
if mode != "r":
raise ValueError("bad mode")

if isPath(fp):
filename = fp
fp = builtins.open(fp, "rb")
else:
filename = ""

try:
return GdImageFile(fp, filename)
return GdImageFile(fp)
except SyntaxError:
raise IOError("cannot identify this image file")
Binary file added Tests/images/gd
Binary file not shown.
17 changes: 17 additions & 0 deletions Tests/test_file_gd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from helper import unittest, PillowTestCase

from PIL import GdImageFile

TEST_GD_FILE = "Tests/images/gd"


class TestFileGd(PillowTestCase):

def test_sanity(self):
im = GdImageFile.open(TEST_GD_FILE)
self.assertEqual(im.size, (10, 20))
self.assertEqual(im.format, "GD")


if __name__ == '__main__':
unittest.main()

0 comments on commit 3b499c6

Please sign in to comment.