diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f2f474941..83e6670ee 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,7 +4,7 @@ Bug fixes, feature additions, tests, documentation and more can be contributed v ## Bug fixes, feature additions, etc. -Please send a pull request to the master branch. Please include [documentation](http://pillow.readthedocs.org) and [tests](Tests/README.rst) for new features. Tests or documentation without bug fixes or feature additions are welcome too. Feel free to ask questions [via issues](https://github.com/python-pillow/Pillow/issues/new) or irc://irc.freenode.net#pil +Please send a pull request to the master branch. Please include [documentation](https://pillow.readthedocs.io) and [tests](../Tests/README.rst) for new features. Tests or documentation without bug fixes or feature additions are welcome too. Feel free to ask questions [via issues](https://github.com/python-pillow/Pillow/issues/new) or irc://irc.freenode.net#pil - Fork the Pillow repository. - Create a branch from master. diff --git a/CHANGES.rst b/CHANGES.rst index 04ee11b4b..d5b8872f4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,21 @@ Changelog (Pillow) 3.3.0 (unreleased) ------------------ +- Added _accept hook for XVThumbImagePlugin #1853 + [radarhere] + +- Test TIFF with LZW compression #1855, TGA RLE file #1854 + [hugovk] + +- Improved SpiderImagePlugin help text #1863 + [radarhere] + +- Updated Sphinx project description #1870 + [radarhere] + +- Remove support for Python 3.0 from _imaging.c #1851 + [radarhere] + - Jpeg qtables are unsigned chars #1814 [thebostik] diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index a59329497..71a51150b 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -293,7 +293,7 @@ Image.register_save(SpiderImageFile.format, _save_spider) if __name__ == "__main__": if not sys.argv[1:]: - print("Syntax: python SpiderImagePlugin.py Spiderimage [outfile]") + print("Syntax: python SpiderImagePlugin.py [infile] [outfile]") sys.exit() filename = sys.argv[1] diff --git a/PIL/XVThumbImagePlugin.py b/PIL/XVThumbImagePlugin.py index 311e65dc0..9fe9ca131 100644 --- a/PIL/XVThumbImagePlugin.py +++ b/PIL/XVThumbImagePlugin.py @@ -23,6 +23,8 @@ __version__ = "0.1" o8 = _binary.o8 +_MAGIC = b"P7 332" + # standard color palette for thumbnails (RGB332) PALETTE = b"" for r in range(8): @@ -30,6 +32,9 @@ for r in range(8): for b in range(4): PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3)) +def _accept(prefix): + return prefix[:6] == _MAGIC + ## # Image plugin for XV thumbnail images. @@ -42,8 +47,7 @@ class XVThumbImageFile(ImageFile.ImageFile): def _open(self): # check magic - s = self.fp.read(6) - if s != b"P7 332": + if self.fp.read(6) != _MAGIC: raise SyntaxError("not an XV thumbnail file") # Skip to beginning of next line @@ -72,4 +76,4 @@ class XVThumbImageFile(ImageFile.ImageFile): # -------------------------------------------------------------------- -Image.register_open(XVThumbImageFile.format, XVThumbImageFile) +Image.register_open(XVThumbImageFile.format, XVThumbImageFile, _accept) diff --git a/README.rst b/README.rst index 13fd77a78..b115a55a4 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,7 @@ Pillow is the friendly PIL fork by `Alex Clark and Contributors `_ +- `Documentation `_ - - `Installation `_ - - `Handbook `_ + - `Installation `_ + - `Handbook `_ - `Contribute `_ diff --git a/Tests/images/hopper_lzw.tif b/Tests/images/hopper_lzw.tif new file mode 100644 index 000000000..568284996 Binary files /dev/null and b/Tests/images/hopper_lzw.tif differ diff --git a/Tests/images/rgb32rle.tga b/Tests/images/rgb32rle.tga new file mode 100644 index 000000000..52633d55d Binary files /dev/null and b/Tests/images/rgb32rle.tga differ diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index 459e766d5..ef3acfe65 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -15,6 +15,16 @@ class TestFileTga(PillowTestCase): # Assert self.assertEqual(im.size, (100, 100)) + def test_id_field_rle(self): + # tga file with id field + test_file = "Tests/images/rgb32rle.tga" + + # Act + im = Image.open(test_file) + + # Assert + self.assertEqual(im.size, (199, 199)) + def test_save(self): test_file = "Tests/images/tga_id_field.tga" im = Image.open(test_file) @@ -34,6 +44,25 @@ class TestFileTga(PillowTestCase): # Unsupported mode save self.assertRaises(IOError, lambda: im.convert("LA").save(test_file)) + def test_save_rle(self): + test_file = "Tests/images/rgb32rle.tga" + im = Image.open(test_file) + + test_file = self.tempfile("temp.tga") + + # Save + im.save(test_file) + test_im = Image.open(test_file) + self.assertEqual(test_im.size, (199, 199)) + + # RGBA save + im.convert("RGBA").save(test_file) + test_im = Image.open(test_file) + self.assertEqual(test_im.size, (199, 199)) + + # Unsupported mode save + self.assertRaises(IOError, lambda: im.convert("LA").save(test_file)) + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 84fdd0f49..ca0816351 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -85,8 +85,10 @@ class TestFileTiff(PillowTestCase): self.assertIsInstance(im.tag[Y_RESOLUTION][0], tuple) # v2 api - self.assertIsInstance(im.tag_v2[X_RESOLUTION], TiffImagePlugin.IFDRational) - self.assertIsInstance(im.tag_v2[Y_RESOLUTION], TiffImagePlugin.IFDRational) + self.assertIsInstance(im.tag_v2[X_RESOLUTION], + TiffImagePlugin.IFDRational) + self.assertIsInstance(im.tag_v2[Y_RESOLUTION], + TiffImagePlugin.IFDRational) self.assertEqual(im.info['dpi'], (72., 72.)) @@ -340,8 +342,8 @@ class TestFileTiff(PillowTestCase): def test_gray_semibyte_per_pixel(self): test_files = ( ( - 24.8,#epsilon - (#group + 24.8, # epsilon + ( # group "Tests/images/tiff_gray_2_4_bpp/hopper2.tif", "Tests/images/tiff_gray_2_4_bpp/hopper2I.tif", "Tests/images/tiff_gray_2_4_bpp/hopper2R.tif", @@ -349,8 +351,8 @@ class TestFileTiff(PillowTestCase): ) ), ( - 7.3,#epsilon - (#group + 7.3, # epsilon + ( # group "Tests/images/tiff_gray_2_4_bpp/hopper4.tif", "Tests/images/tiff_gray_2_4_bpp/hopper4I.tif", "Tests/images/tiff_gray_2_4_bpp/hopper4R.tif", @@ -424,16 +426,16 @@ class TestFileTiff(PillowTestCase): im = Image.open('Tests/images/compression.tif') im.seek(0) - self.assertEqual(im._compression,'tiff_ccitt') + self.assertEqual(im._compression, 'tiff_ccitt') self.assertEqual(im.size, (10, 10)) im.seek(1) - self.assertEqual(im._compression,'packbits') + self.assertEqual(im._compression, 'packbits') self.assertEqual(im.size, (10, 10)) im.load() im.seek(0) - self.assertEqual(im._compression,'tiff_ccitt') + self.assertEqual(im._compression, 'tiff_ccitt') self.assertEqual(im.size, (10, 10)) im.load() @@ -450,6 +452,18 @@ class TestFileTiff(PillowTestCase): # Should not raise UnicodeDecodeError or anything else im.save(outfile) + def test_lzw(self): + # Act + im = Image.open("Tests/images/hopper_lzw.tif") + + # Assert + self.assertEqual(im.mode, 'RGB') + self.assertEqual(im.size, (128, 128)) + self.assertEqual(im.format, "TIFF") + im2 = hopper() + self.assert_image_similar(im, im2, 5) + + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_psdraw.py b/Tests/test_psdraw.py index 427c6c707..c657f2dbe 100644 --- a/Tests/test_psdraw.py +++ b/Tests/test_psdraw.py @@ -31,7 +31,7 @@ class TestPsDraw(PillowTestCase): def test_draw_postscript(self): # Based on Pillow tutorial, but there is no textsize: - # http://pillow.readthedocs.org/en/latest/handbook/tutorial.html + # https://pillow.readthedocs.io/en/latest/handbook/tutorial.html # Arrange tempfile = self.tempfile('temp.ps') diff --git a/_imaging.c b/_imaging.c index 12ed32168..1077f0b57 100644 --- a/_imaging.c +++ b/_imaging.c @@ -3142,7 +3142,7 @@ _getattr_id(ImagingObject* self, void* closure) static PyObject* _getattr_ptr(ImagingObject* self, void* closure) { -#if (PY_VERSION_HEX >= 0x02070000 && PY_VERSION_HEX < 0x03000000) || PY_VERSION_HEX >= 0x03010000 +#if PY_VERSION_HEX >= 0x02070000 return PyCapsule_New(self->image, IMAGING_MAGIC, NULL); #else return PyCObject_FromVoidPtrAndDesc(self->image, IMAGING_MAGIC, NULL); diff --git a/docs/conf.py b/docs/conf.py index a1d09cd34..f66bea521 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -272,7 +272,7 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation', - author, 'PillowPILFork', 'One line description of project.', + author, 'PillowPILFork', 'Pillow is the friendly PIL fork by Alex Clark and Contributors.', 'Miscellaneous'), ] diff --git a/docs/index.rst b/docs/index.rst index d7bd95b9a..9ec56e117 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,7 +7,7 @@ Pillow is the friendly PIL fork by `Alex Clark and Contributors