mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-16 02:04:45 +03:00
Merge remote-tracking branch 'upstream/master' into tests-for-open-bugs
This commit is contained in:
commit
dd9f1a8731
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
|
@ -4,7 +4,7 @@ Bug fixes, feature additions, tests, documentation and more can be contributed v
|
||||||
|
|
||||||
## Bug fixes, feature additions, etc.
|
## 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.
|
- Fork the Pillow repository.
|
||||||
- Create a branch from master.
|
- Create a branch from master.
|
||||||
|
|
15
CHANGES.rst
15
CHANGES.rst
|
@ -4,6 +4,21 @@ Changelog (Pillow)
|
||||||
3.3.0 (unreleased)
|
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
|
- Jpeg qtables are unsigned chars #1814
|
||||||
[thebostik]
|
[thebostik]
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ Image.register_save(SpiderImageFile.format, _save_spider)
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
if not sys.argv[1:]:
|
if not sys.argv[1:]:
|
||||||
print("Syntax: python SpiderImagePlugin.py Spiderimage [outfile]")
|
print("Syntax: python SpiderImagePlugin.py [infile] [outfile]")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
|
|
|
@ -23,6 +23,8 @@ __version__ = "0.1"
|
||||||
|
|
||||||
o8 = _binary.o8
|
o8 = _binary.o8
|
||||||
|
|
||||||
|
_MAGIC = b"P7 332"
|
||||||
|
|
||||||
# standard color palette for thumbnails (RGB332)
|
# standard color palette for thumbnails (RGB332)
|
||||||
PALETTE = b""
|
PALETTE = b""
|
||||||
for r in range(8):
|
for r in range(8):
|
||||||
|
@ -30,6 +32,9 @@ for r in range(8):
|
||||||
for b in range(4):
|
for b in range(4):
|
||||||
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
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.
|
# Image plugin for XV thumbnail images.
|
||||||
|
@ -42,8 +47,7 @@ class XVThumbImageFile(ImageFile.ImageFile):
|
||||||
def _open(self):
|
def _open(self):
|
||||||
|
|
||||||
# check magic
|
# check magic
|
||||||
s = self.fp.read(6)
|
if self.fp.read(6) != _MAGIC:
|
||||||
if s != b"P7 332":
|
|
||||||
raise SyntaxError("not an XV thumbnail file")
|
raise SyntaxError("not an XV thumbnail file")
|
||||||
|
|
||||||
# Skip to beginning of next line
|
# 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)
|
||||||
|
|
|
@ -19,7 +19,7 @@ Pillow is the friendly PIL fork by `Alex Clark and Contributors <https://github.
|
||||||
- |zenodo| |version| |downloads|
|
- |zenodo| |version| |downloads|
|
||||||
|
|
||||||
.. |docs| image:: https://readthedocs.org/projects/pillow/badge/?version=latest
|
.. |docs| image:: https://readthedocs.org/projects/pillow/badge/?version=latest
|
||||||
:target: http://pillow.readthedocs.org/?badge=latest
|
:target: https://pillow.readthedocs.io/?badge=latest
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
.. |linux| image:: https://img.shields.io/travis/python-pillow/Pillow/master.svg?label=Linux%20build
|
.. |linux| image:: https://img.shields.io/travis/python-pillow/Pillow/master.svg?label=Linux%20build
|
||||||
|
@ -60,10 +60,10 @@ Pillow is the friendly PIL fork by `Alex Clark and Contributors <https://github.
|
||||||
More Information
|
More Information
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
- `Documentation <https://pillow.readthedocs.org/>`_
|
- `Documentation <https://pillow.readthedocs.io/>`_
|
||||||
|
|
||||||
- `Installation <https://pillow.readthedocs.org/en/latest/installation.html>`_
|
- `Installation <https://pillow.readthedocs.io/en/latest/installation.html>`_
|
||||||
- `Handbook <https://pillow.readthedocs.org/en/latest/handbook/index.html>`_
|
- `Handbook <https://pillow.readthedocs.io/en/latest/handbook/index.html>`_
|
||||||
|
|
||||||
- `Contribute <https://github.com/python-pillow/Pillow/blob/master/.github/CONTRIBUTING.md>`_
|
- `Contribute <https://github.com/python-pillow/Pillow/blob/master/.github/CONTRIBUTING.md>`_
|
||||||
|
|
||||||
|
|
BIN
Tests/images/hopper_lzw.tif
Normal file
BIN
Tests/images/hopper_lzw.tif
Normal file
Binary file not shown.
BIN
Tests/images/rgb32rle.tga
Normal file
BIN
Tests/images/rgb32rle.tga
Normal file
Binary file not shown.
|
@ -15,6 +15,16 @@ class TestFileTga(PillowTestCase):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(im.size, (100, 100))
|
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):
|
def test_save(self):
|
||||||
test_file = "Tests/images/tga_id_field.tga"
|
test_file = "Tests/images/tga_id_field.tga"
|
||||||
im = Image.open(test_file)
|
im = Image.open(test_file)
|
||||||
|
@ -34,6 +44,25 @@ class TestFileTga(PillowTestCase):
|
||||||
# Unsupported mode save
|
# Unsupported mode save
|
||||||
self.assertRaises(IOError, lambda: im.convert("LA").save(test_file))
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -85,8 +85,10 @@ class TestFileTiff(PillowTestCase):
|
||||||
self.assertIsInstance(im.tag[Y_RESOLUTION][0], tuple)
|
self.assertIsInstance(im.tag[Y_RESOLUTION][0], tuple)
|
||||||
|
|
||||||
# v2 api
|
# v2 api
|
||||||
self.assertIsInstance(im.tag_v2[X_RESOLUTION], TiffImagePlugin.IFDRational)
|
self.assertIsInstance(im.tag_v2[X_RESOLUTION],
|
||||||
self.assertIsInstance(im.tag_v2[Y_RESOLUTION], TiffImagePlugin.IFDRational)
|
TiffImagePlugin.IFDRational)
|
||||||
|
self.assertIsInstance(im.tag_v2[Y_RESOLUTION],
|
||||||
|
TiffImagePlugin.IFDRational)
|
||||||
|
|
||||||
self.assertEqual(im.info['dpi'], (72., 72.))
|
self.assertEqual(im.info['dpi'], (72., 72.))
|
||||||
|
|
||||||
|
@ -340,8 +342,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
def test_gray_semibyte_per_pixel(self):
|
def test_gray_semibyte_per_pixel(self):
|
||||||
test_files = (
|
test_files = (
|
||||||
(
|
(
|
||||||
24.8,#epsilon
|
24.8, # epsilon
|
||||||
(#group
|
( # group
|
||||||
"Tests/images/tiff_gray_2_4_bpp/hopper2.tif",
|
"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/hopper2I.tif",
|
||||||
"Tests/images/tiff_gray_2_4_bpp/hopper2R.tif",
|
"Tests/images/tiff_gray_2_4_bpp/hopper2R.tif",
|
||||||
|
@ -349,8 +351,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
7.3,#epsilon
|
7.3, # epsilon
|
||||||
(#group
|
( # group
|
||||||
"Tests/images/tiff_gray_2_4_bpp/hopper4.tif",
|
"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/hopper4I.tif",
|
||||||
"Tests/images/tiff_gray_2_4_bpp/hopper4R.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 = Image.open('Tests/images/compression.tif')
|
||||||
|
|
||||||
im.seek(0)
|
im.seek(0)
|
||||||
self.assertEqual(im._compression,'tiff_ccitt')
|
self.assertEqual(im._compression, 'tiff_ccitt')
|
||||||
self.assertEqual(im.size, (10, 10))
|
self.assertEqual(im.size, (10, 10))
|
||||||
|
|
||||||
im.seek(1)
|
im.seek(1)
|
||||||
self.assertEqual(im._compression,'packbits')
|
self.assertEqual(im._compression, 'packbits')
|
||||||
self.assertEqual(im.size, (10, 10))
|
self.assertEqual(im.size, (10, 10))
|
||||||
im.load()
|
im.load()
|
||||||
|
|
||||||
im.seek(0)
|
im.seek(0)
|
||||||
self.assertEqual(im._compression,'tiff_ccitt')
|
self.assertEqual(im._compression, 'tiff_ccitt')
|
||||||
self.assertEqual(im.size, (10, 10))
|
self.assertEqual(im.size, (10, 10))
|
||||||
im.load()
|
im.load()
|
||||||
|
|
||||||
|
@ -450,6 +452,18 @@ class TestFileTiff(PillowTestCase):
|
||||||
# Should not raise UnicodeDecodeError or anything else
|
# Should not raise UnicodeDecodeError or anything else
|
||||||
im.save(outfile)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TestPsDraw(PillowTestCase):
|
||||||
def test_draw_postscript(self):
|
def test_draw_postscript(self):
|
||||||
|
|
||||||
# Based on Pillow tutorial, but there is no textsize:
|
# 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
|
# Arrange
|
||||||
tempfile = self.tempfile('temp.ps')
|
tempfile = self.tempfile('temp.ps')
|
||||||
|
|
|
@ -3142,7 +3142,7 @@ _getattr_id(ImagingObject* self, void* closure)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
_getattr_ptr(ImagingObject* self, void* closure)
|
_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);
|
return PyCapsule_New(self->image, IMAGING_MAGIC, NULL);
|
||||||
#else
|
#else
|
||||||
return PyCObject_FromVoidPtrAndDesc(self->image, IMAGING_MAGIC, NULL);
|
return PyCObject_FromVoidPtrAndDesc(self->image, IMAGING_MAGIC, NULL);
|
||||||
|
|
|
@ -272,7 +272,7 @@ man_pages = [
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation',
|
(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'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ Pillow is the friendly PIL fork by `Alex Clark and Contributors <https://github.
|
||||||
:target: https://zenodo.org/badge/latestdoi/17549/python-pillow/Pillow
|
:target: https://zenodo.org/badge/latestdoi/17549/python-pillow/Pillow
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/pillow/badge/?version=latest
|
.. image:: https://readthedocs.org/projects/pillow/badge/?version=latest
|
||||||
:target: http://pillow.readthedocs.org/?badge=latest
|
:target: https://pillow.readthedocs.io/?badge=latest
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
.. image:: https://travis-ci.org/python-pillow/Pillow.svg?branch=master
|
.. image:: https://travis-ci.org/python-pillow/Pillow.svg?branch=master
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -734,7 +734,7 @@ class pil_build_ext(build_ext):
|
||||||
if not all:
|
if not all:
|
||||||
print("To add a missing option, make sure you have the required")
|
print("To add a missing option, make sure you have the required")
|
||||||
print("library and headers.")
|
print("library and headers.")
|
||||||
print("See https://pillow.readthedocs.org/en/latest/installation.html#building-from-source")
|
print("See https://pillow.readthedocs.io/en/latest/installation.html#building-from-source")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
print("To check the build, run the selftest.py script.")
|
print("To check the build, run the selftest.py script.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user