diff --git a/Images/lena.tar b/Images/lena.tar new file mode 100644 index 000000000..3afb1f542 Binary files /dev/null and b/Images/lena.tar differ diff --git a/PIL/TarIO.py b/PIL/TarIO.py index 73e3fc48a..37518e286 100644 --- a/PIL/TarIO.py +++ b/PIL/TarIO.py @@ -39,13 +39,13 @@ class TarIO(ContainerIO.ContainerIO): raise IOError("unexpected end of tar file") name = s[:100].decode('utf-8') - i = name.find(b'\0') + i = name.find('\0') if i == 0: raise IOError("cannot find subfile") if i > 0: name = name[:i] - size = int(s[124:136], 8) + size = int(s[124:135], 8) if file == name: break diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py new file mode 100644 index 000000000..0f87ea2c0 --- /dev/null +++ b/Tests/test_file_tar.py @@ -0,0 +1,22 @@ +from tester import * + +from PIL import Image, TarIO + +# sample ppm stream +tarfile = "Images/lena.tar" + +def test_sanity(): + tar = TarIO.TarIO(tarfile, 'lena.png') + im = Image.open(tar) + im.load() + assert_equal(im.mode, "RGB") + assert_equal(im.size, (128, 128)) + assert_equal(im.format, "PNG") + + tar = TarIO.TarIO(tarfile, 'lena.jpg') + im = Image.open(tar) + im.load() + assert_equal(im.mode, "RGB") + assert_equal(im.size, (128, 128)) + assert_equal(im.format, "JPEG") +