mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-26 23:24:45 +03:00
Trim trailing whitespace from all source files throughout project
Many editors trim whitespace by default. When newcomers are submitting patches, it is often undesirable to see inadvertent whitespace changes in the diff as it is distracting and unrelated. To make contributing easier, clean up all whitespace in one go across the project. Will allow for cleaner diffs in the future. Contributors will not need to worry about automatic yet inadvertent whitespace changes.
This commit is contained in:
parent
92bb1b5f06
commit
45f5e8e092
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
|
@ -8,7 +8,7 @@
|
|||
|
||||
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.
|
||||
|
||||
The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.
|
||||
The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.
|
||||
|
||||
```python
|
||||
code goes here
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -68,4 +68,3 @@ docs/_build/
|
|||
|
||||
#OS
|
||||
.DS_Store
|
||||
|
||||
|
|
|
@ -32,4 +32,3 @@ pushd depends && ./install_imagequant.sh && popd
|
|||
|
||||
# extra test images
|
||||
pushd depends && ./install_extra_test_images.sh && popd
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Changelog (Pillow)
|
||||
==================
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
include *.c
|
||||
include *.h
|
||||
include *.in
|
||||
|
|
|
@ -42,7 +42,7 @@ class DcxImageFile(PcxImageFile):
|
|||
format = "DCX"
|
||||
format_description = "Intel DCX"
|
||||
_close_exclusive_fp_after_loading = False
|
||||
|
||||
|
||||
def _open(self):
|
||||
|
||||
# Header
|
||||
|
|
|
@ -2100,7 +2100,7 @@ class Image(object):
|
|||
in the output image.
|
||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||
"""
|
||||
|
||||
|
||||
if self.mode == 'LA':
|
||||
return self.convert('La').transform(
|
||||
size, method, data, resample, fill).convert('LA')
|
||||
|
|
|
@ -278,7 +278,7 @@ class BitmapImage(object):
|
|||
|
||||
def getimage(photo):
|
||||
""" This function is unimplemented """
|
||||
|
||||
|
||||
"""Copies the contents of a PhotoImage to a PIL image memory."""
|
||||
photo.tk.call("PyImagingPhotoGet", photo)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
|
|||
format = "MPO"
|
||||
format_description = "MPO (CIPA DC-007)"
|
||||
_close_exclusive_fp_after_loading = False
|
||||
|
||||
|
||||
def _open(self):
|
||||
self.fp.seek(0) # prep the fp in order to pass the JPEG test
|
||||
JpegImagePlugin.JpegImageFile._open(self)
|
||||
|
|
|
@ -143,7 +143,7 @@ TAGS_V2 = {
|
|||
342: ("TransferRange", SHORT, 6),
|
||||
|
||||
347: ("JPEGTables", UNDEFINED, 1),
|
||||
|
||||
|
||||
# obsolete JPEG tags
|
||||
512: ("JPEGProc", SHORT, 1),
|
||||
513: ("JPEGInterchangeFormat", LONG, 1),
|
||||
|
@ -161,7 +161,7 @@ TAGS_V2 = {
|
|||
532: ("ReferenceBlackWhite", LONG, 0),
|
||||
|
||||
700: ('XMP', BYTE, 1),
|
||||
|
||||
|
||||
33432: ("Copyright", ASCII, 1),
|
||||
34377: ('PhotoshopInfo', BYTE, 1),
|
||||
|
||||
|
@ -193,7 +193,7 @@ TAGS_V2 = {
|
|||
|
||||
50741: ("MakerNoteSafety", SHORT, 1, {"Unsafe": 0, "Safe": 1}),
|
||||
50780: ("BestQualityScale", RATIONAL, 1),
|
||||
50838: ("ImageJMetaDataByteCounts", LONG, 0), # Can be more than one
|
||||
50838: ("ImageJMetaDataByteCounts", LONG, 0), # Can be more than one
|
||||
50839: ("ImageJMetaData", UNDEFINED, 1) # see Issue #2006
|
||||
}
|
||||
|
||||
|
|
|
@ -76,4 +76,3 @@ def get_supported():
|
|||
ret.extend(get_supported_features())
|
||||
ret.extend(get_supported_codecs())
|
||||
return ret
|
||||
|
||||
|
|
|
@ -39,6 +39,3 @@ To run an individual test::
|
|||
Run all the tests from the root of the Pillow source distribution::
|
||||
|
||||
./test-installed.py
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class PillowTestCase(unittest.TestCase):
|
|||
logger.error("Url for test images: %s" %url)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
self.fail(msg or "got different content")
|
||||
|
||||
def assert_image_similar(self, a, b, epsilon, msg=None):
|
||||
|
@ -206,7 +206,7 @@ class PillowLeakTestCase(PillowTestCase):
|
|||
# requires unix/osx
|
||||
iterations = 100 # count
|
||||
mem_limit = 512 # k
|
||||
|
||||
|
||||
def _get_mem_usage(self):
|
||||
"""
|
||||
Gets the RUSAGE memory usage, returns in K. Encapsulates the difference
|
||||
|
@ -214,7 +214,7 @@ class PillowLeakTestCase(PillowTestCase):
|
|||
|
||||
:returns; memory usage in kilobytes
|
||||
"""
|
||||
|
||||
|
||||
from resource import getpagesize, getrusage, RUSAGE_SELF
|
||||
mem = getrusage(RUSAGE_SELF).ru_maxrss
|
||||
if sys.platform == 'darwin':
|
||||
|
@ -225,7 +225,7 @@ class PillowLeakTestCase(PillowTestCase):
|
|||
# linux
|
||||
# man 2 getrusage
|
||||
# ru_maxrss (since Linux 2.6.32)
|
||||
# This is the maximum resident set size used (in kilobytes).
|
||||
# This is the maximum resident set size used (in kilobytes).
|
||||
return mem # Kb
|
||||
|
||||
def _test_leak(self, core):
|
||||
|
|
|
@ -22,4 +22,3 @@ and that the name of ICC shall not be used in advertising or publicity
|
|||
pertaining to distribution of the software without specific, written
|
||||
prior permission. ICC makes no representations about the suitability
|
||||
of this software for any purpose.
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class TestFileSgi(PillowTestCase):
|
|||
|
||||
reloaded = Image.open(out)
|
||||
self.assert_image_equal(im, reloaded)
|
||||
|
||||
|
||||
def test_unsupported_mode(self):
|
||||
im = hopper('LA')
|
||||
out = self.tempfile('temp.sgi')
|
||||
|
|
|
@ -70,7 +70,7 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
self.assertAlmostEqual(loaded_double, doubledata)
|
||||
|
||||
# check with 2 element ImageJMetaDataByteCounts, issue #2006
|
||||
|
||||
|
||||
info[ImageJMetaDataByteCounts] = (8, len(bindata) - 8)
|
||||
img.save(f, tiffinfo=info)
|
||||
loaded = Image.open(f)
|
||||
|
|
|
@ -14,7 +14,7 @@ class TestTTypeFontLeak(PillowLeakTestCase):
|
|||
draw = ImageDraw.ImageDraw(im)
|
||||
self._test_leak(lambda: draw.text((0, 0), "some text "*1024, #~10k
|
||||
font=font, fill="black"))
|
||||
|
||||
|
||||
@unittest.skipIf(not features.check('freetype2'), "Test requires freetype2")
|
||||
def test_leak(self):
|
||||
ttype = ImageFont.truetype('Tests/fonts/FreeMono.ttf', 20)
|
||||
|
@ -24,7 +24,7 @@ class TestDefaultFontLeak(TestTTypeFontLeak):
|
|||
# fails at iteration 37 in master
|
||||
iterations = 100
|
||||
mem_limit = 1024 #k
|
||||
|
||||
|
||||
def test_leak(self):
|
||||
default_font = ImageFont.load_default()
|
||||
self._test_font(default_font)
|
||||
|
|
|
@ -51,7 +51,7 @@ class TestFontPcf(PillowTestCase):
|
|||
draw.text((0, 0), message, 'black', font=font)
|
||||
with Image.open('Tests/images/test_draw_pbm_target.png') as target:
|
||||
self.assert_image_similar(im, target, 0)
|
||||
|
||||
|
||||
def test_textsize(self):
|
||||
tempname = self.save_font()
|
||||
font = ImageFont.load(tempname)
|
||||
|
|
|
@ -293,7 +293,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
compiler = ccompiler.new_compiler()
|
||||
compiler.add_include_dir(sysconfig.get_python_inc())
|
||||
|
||||
|
||||
libdir = sysconfig.get_config_var('LIBDIR') or sysconfig.get_python_inc().replace('include', 'libs')
|
||||
print (libdir)
|
||||
compiler.add_library_dir(libdir)
|
||||
|
@ -302,10 +302,10 @@ int main(int argc, char* argv[])
|
|||
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = sys.prefix + ';' + env["PATH"]
|
||||
|
||||
|
||||
# do not display the Windows Error Reporting dialog
|
||||
ctypes.windll.kernel32.SetErrorMode(0x0002)
|
||||
|
||||
|
||||
process = subprocess.Popen(['embed_pil.exe'], env=env)
|
||||
process.communicate()
|
||||
self.assertEqual(process.returncode, 0)
|
||||
|
|
|
@ -89,7 +89,7 @@ class TestImageConvert(PillowTestCase):
|
|||
self.assertNotIn('transparency', rgba.info)
|
||||
# https://github.com/python-pillow/Pillow/issues/2702
|
||||
self.assertEqual(rgba.palette, None)
|
||||
|
||||
|
||||
|
||||
def test_trns_l(self):
|
||||
im = hopper('L')
|
||||
|
|
|
@ -406,10 +406,10 @@ class TestImageFont(PillowTestCase):
|
|||
im = Image.new(mode='RGB', size=(300, 100))
|
||||
target = im.copy()
|
||||
draw = ImageDraw.Draw(im)
|
||||
#should not crash here.
|
||||
#should not crash here.
|
||||
draw.text((10, 10), '', font=font)
|
||||
self.assert_image_equal(im, target)
|
||||
|
||||
|
||||
def test_unicode_pilfont(self):
|
||||
# should not segfault, should return UnicodeDecodeError
|
||||
# issue #2826
|
||||
|
|
|
@ -15,8 +15,8 @@ class TestImagecomplextext(PillowTestCase):
|
|||
im = Image.new(mode='RGB', size=(300, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
draw.text((0, 0), 'TEST', font=ttf, fill=500, direction='ltr')
|
||||
|
||||
|
||||
|
||||
|
||||
def test_complex_text(self):
|
||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
|
||||
|
@ -102,7 +102,7 @@ class TestImagecomplextext(PillowTestCase):
|
|||
|
||||
liga_size = ttf.getsize('fi', features=['-liga'])
|
||||
self.assertEqual(liga_size,(13,19))
|
||||
|
||||
|
||||
def test_kerning_features(self):
|
||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ class TestLibUnpack(PillowTestCase):
|
|||
self.assert_unpack("L", "L;R", 1, 128, 64, 192, 32)
|
||||
self.assert_unpack("L", "L;16", 2, 2, 4, 6, 8)
|
||||
self.assert_unpack("L", "L;16B", 2, 1, 3, 5, 7)
|
||||
self.assert_unpack("L", "L;16", b'\x00\xc6\x00\xaf', 198, 175)
|
||||
self.assert_unpack("L", "L;16", b'\x00\xc6\x00\xaf', 198, 175)
|
||||
self.assert_unpack("L", "L;16B", b'\xc6\x00\xaf\x00', 198, 175)
|
||||
|
||||
|
||||
|
|
21
_imaging.c
21
_imaging.c
|
@ -1499,11 +1499,11 @@ _resize(ImagingObject* self, PyObject* args)
|
|||
int xsize, ysize;
|
||||
int filter = IMAGING_TRANSFORM_NEAREST;
|
||||
float box[4] = {0, 0, 0, 0};
|
||||
|
||||
|
||||
imIn = self->image;
|
||||
box[2] = imIn->xsize;
|
||||
box[3] = imIn->ysize;
|
||||
|
||||
|
||||
if (!PyArg_ParseTuple(args, "(ii)|i(ffff)", &xsize, &ysize, &filter,
|
||||
&box[0], &box[1], &box[2], &box[3]))
|
||||
return NULL;
|
||||
|
@ -3345,7 +3345,7 @@ _reset_stats(PyObject* self, PyObject* args)
|
|||
|
||||
if (!PyArg_ParseTuple(args, ":reset_stats"))
|
||||
return NULL;
|
||||
|
||||
|
||||
arena->stats_new_count = 0;
|
||||
arena->stats_allocated_blocks = 0;
|
||||
arena->stats_reused_blocks = 0;
|
||||
|
@ -3361,7 +3361,7 @@ _get_alignment(PyObject* self, PyObject* args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args, ":get_alignment"))
|
||||
return NULL;
|
||||
|
||||
|
||||
return PyInt_FromLong(ImagingDefaultArena.alignment);
|
||||
}
|
||||
|
||||
|
@ -3370,7 +3370,7 @@ _get_block_size(PyObject* self, PyObject* args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args, ":get_block_size"))
|
||||
return NULL;
|
||||
|
||||
|
||||
return PyInt_FromLong(ImagingDefaultArena.block_size);
|
||||
}
|
||||
|
||||
|
@ -3379,7 +3379,7 @@ _get_blocks_max(PyObject* self, PyObject* args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args, ":get_blocks_max"))
|
||||
return NULL;
|
||||
|
||||
|
||||
return PyInt_FromLong(ImagingDefaultArena.blocks_max);
|
||||
}
|
||||
|
||||
|
@ -3389,7 +3389,7 @@ _set_alignment(PyObject* self, PyObject* args)
|
|||
int alignment;
|
||||
if (!PyArg_ParseTuple(args, "i:set_alignment", &alignment))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (alignment < 1 || alignment > 128) {
|
||||
PyErr_SetString(PyExc_ValueError, "alignment should be from 1 to 128");
|
||||
return NULL;
|
||||
|
@ -3412,7 +3412,7 @@ _set_block_size(PyObject* self, PyObject* args)
|
|||
int block_size;
|
||||
if (!PyArg_ParseTuple(args, "i:set_block_size", &block_size))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (block_size <= 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"block_size should be greater than 0");
|
||||
|
@ -3437,7 +3437,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
|
|||
int blocks_max;
|
||||
if (!PyArg_ParseTuple(args, "i:set_blocks_max", &blocks_max))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (blocks_max < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"blocks_max should be greater than 0");
|
||||
|
@ -3460,7 +3460,7 @@ _clear_cache(PyObject* self, PyObject* args)
|
|||
|
||||
if (!PyArg_ParseTuple(args, "|i:clear_cache", &i))
|
||||
return NULL;
|
||||
|
||||
|
||||
ImagingMemoryClearCache(&ImagingDefaultArena, i);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -3718,4 +3718,3 @@ init_imaging(void)
|
|||
setup_module(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|is"PY_ARG_BYTES_LENGTH"i",
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|is"PY_ARG_BYTES_LENGTH"i",
|
||||
kwlist,
|
||||
Py_FileSystemDefaultEncoding, &filename,
|
||||
&size, &index, &encoding, &font_bytes,
|
||||
|
@ -513,7 +513,7 @@ font_getsize(FontObject* self, PyObject* args)
|
|||
PyMem_Free(glyph_info);
|
||||
glyph_info = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (face) {
|
||||
|
||||
/* left bearing */
|
||||
|
@ -891,4 +891,3 @@ init_imagingft(void)
|
|||
setup_module(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -301,4 +301,3 @@ init_imagingmath(void)
|
|||
setup_module(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -301,4 +301,3 @@ init_imagingmorph(void)
|
|||
setup_module(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -86,4 +86,3 @@ init_imagingtk(void)
|
|||
load_tkinter_funcs();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
1
decode.c
1
decode.c
|
@ -942,4 +942,3 @@ PyImaging_Jpeg2KDecoderNew(PyObject* self, PyObject* args)
|
|||
return (PyObject*) decoder;
|
||||
}
|
||||
#endif /* HAVE_OPENJPEG */
|
||||
|
||||
|
|
|
@ -24,4 +24,3 @@ e.g.::
|
|||
$ source ~/vpy27/bin/activate
|
||||
$ make install
|
||||
$ make test
|
||||
|
||||
|
|
|
@ -11,4 +11,3 @@ pushd $archive
|
|||
./configure --prefix=/usr && make -j4 && sudo make -j4 install
|
||||
|
||||
popd
|
||||
|
||||
|
|
|
@ -15,4 +15,3 @@ make && sudo make install
|
|||
cd ..
|
||||
|
||||
popd
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
pkg -y install python python-dev ndk-sysroot clang make \
|
||||
libjpeg-turbo-dev
|
||||
|
||||
libjpeg-turbo-dev
|
||||
|
|
|
@ -150,4 +150,3 @@ can be found here.
|
|||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
|
|
@ -413,5 +413,3 @@ Python-based file decoder:
|
|||
called with a buffer of data to be interpreted.
|
||||
|
||||
3. Cleanup: The decoder instance's ``cleanup`` method is called.
|
||||
|
||||
|
||||
|
|
|
@ -168,10 +168,10 @@ Instances of the :py:class:`Image` class have the following attributes:
|
|||
|
||||
.. py:attribute:: filename
|
||||
|
||||
The filename or path of the source file. Only images created with the
|
||||
factory function `open` have a filename attribute. If the input is a
|
||||
The filename or path of the source file. Only images created with the
|
||||
factory function `open` have a filename attribute. If the input is a
|
||||
file like object, the filename attribute is set to an empty string.
|
||||
|
||||
|
||||
:type: :py:class: `string`
|
||||
|
||||
.. py:attribute:: format
|
||||
|
|
|
@ -40,8 +40,8 @@ variables:
|
|||
|
||||
* ``PILLOW_BLOCK_SIZE``, in bytes, K, or M. Specifies the maximum
|
||||
block size for ``ImagingAllocateArray``. Valid values are
|
||||
integers, with an optional `k` or `m` suffix. Defaults to 16M.
|
||||
integers, with an optional `k` or `m` suffix. Defaults to 16M.
|
||||
|
||||
* ``PILLOW_BLOCKS_MAX`` Specifies the number of freed blocks to
|
||||
retain to fill future memory requests. Any freed blocks over this
|
||||
threshold will be returned to the OS immediately. Defaults to 0.
|
||||
threshold will be returned to the OS immediately. Defaults to 0.
|
||||
|
|
|
@ -3,8 +3,7 @@ Internal Reference Docs
|
|||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
open_files
|
||||
limits
|
||||
block_allocator
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ File Handling in Pillow
|
|||
When opening a file as an image, Pillow requires a filename,
|
||||
pathlib.Path object, or a file-like object. Pillow uses the filename
|
||||
or Path to open a file, so for the rest of this article, they will all
|
||||
be treated as a file-like object.
|
||||
be treated as a file-like object.
|
||||
|
||||
The first four of these items are equivalent, the last is dangerous
|
||||
and may fail::
|
||||
|
@ -12,14 +12,14 @@ and may fail::
|
|||
from PIL import Image
|
||||
import io
|
||||
import pathlib
|
||||
|
||||
|
||||
im = Image.open('test.jpg')
|
||||
|
||||
im2 = Image.open(pathlib.Path('test.jpg'))
|
||||
|
||||
f = open('test.jpg', 'rb')
|
||||
im3 = Image.open(f)
|
||||
|
||||
|
||||
with open('test.jpg', 'rb') as f:
|
||||
im4 = Image.open(io.BytesIO(f.read()))
|
||||
|
||||
|
@ -31,10 +31,10 @@ and may fail::
|
|||
The documentation specifies that the file will be closed after the
|
||||
``Image.Image.load()`` method is called. This is an aspirational
|
||||
specification rather than an accurate reflection of the state of the
|
||||
code.
|
||||
code.
|
||||
|
||||
Pillow cannot in general close and reopen a file, so any access to
|
||||
that file needs to be prior to the close.
|
||||
that file needs to be prior to the close.
|
||||
|
||||
Issues
|
||||
------
|
||||
|
@ -44,10 +44,10 @@ The current open file handling is inconsistent at best:
|
|||
* Most of the image plugins do not close the input file.
|
||||
* Multi-frame images behave badly when seeking through the file, as
|
||||
it's legal to seek backward in the file until the last image is
|
||||
read, and then it's not.
|
||||
read, and then it's not.
|
||||
* Using the file context manager to provide a file-like object to
|
||||
Pillow is dangerous unless the context of the image is limited to
|
||||
the context of the file.
|
||||
the context of the file.
|
||||
|
||||
Image Lifecycle
|
||||
---------------
|
||||
|
@ -59,7 +59,7 @@ Image Lifecycle
|
|||
* ``Image.Image.load()`` when the pixel data from the image is
|
||||
required, ``load()`` is called. The current frame is read into
|
||||
memory. The image can now be used independently of the underlying
|
||||
image file.
|
||||
image file.
|
||||
|
||||
* ``Image.Image.seek()`` in the case of multi-frame images
|
||||
(e.g. multipage TIFF and animated GIF) the image file left open so
|
||||
|
@ -72,12 +72,12 @@ Image Lifecycle
|
|||
support. e.g.::
|
||||
|
||||
with Image.open('test.jpg') as img:
|
||||
... # image operations here.
|
||||
... # image operations here.
|
||||
|
||||
|
||||
The lifecycle of a single frame image is relatively simple. The file
|
||||
must remain open until the ``load()`` or ``close()`` function is
|
||||
called.
|
||||
called.
|
||||
|
||||
Multi-frame images are more complicated. The ``load()`` method is not
|
||||
a terminal method, so it should not close the underlying file. The
|
||||
|
@ -85,7 +85,7 @@ current behavior of ``seek()`` closing the underlying file on
|
|||
accessing the last frame is presumably a heuristic for closing the
|
||||
file after iterating through the entire sequence. In general, Pillow
|
||||
does not know if there are going to be any requests for additional
|
||||
data until the caller has explicitly closed the image.
|
||||
data until the caller has explicitly closed the image.
|
||||
|
||||
|
||||
Complications
|
||||
|
@ -94,7 +94,7 @@ Complications
|
|||
* TiffImagePlugin has some code to pass the underlying file descriptor
|
||||
into libtiff (if working on an actual file). Since libtiff closes
|
||||
the file descriptor internally, it is duplicated prior to passing it
|
||||
into libtiff.
|
||||
into libtiff.
|
||||
|
||||
* ``decoder.handles_eof`` This slightly misnamed flag indicates that
|
||||
the decoder wants to be called with a 0 length buffer when reads are
|
||||
|
@ -118,8 +118,7 @@ Proposed File Handling
|
|||
* ``Image.Image.load()`` should close the image file, unless there are
|
||||
multiple frames.
|
||||
|
||||
* ``Image.Image.seek()`` should never close the image file.
|
||||
* ``Image.Image.seek()`` should never close the image file.
|
||||
|
||||
* Users of the library should call ``Image.Image.close()`` on any
|
||||
multi-frame image to ensure that the underlying file is closed.
|
||||
|
||||
multi-frame image to ensure that the underlying file is closed.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.0.0
|
||||
=====
|
||||
|
||||
|
@ -49,4 +48,3 @@ The external dependencies on libjpeg and zlib are now required by default.
|
|||
If the headers or libraries are not found, then installation will abort
|
||||
with an error. This behaviour can be disabled with the ``--disable-libjpeg``
|
||||
and ``--disable-zlib`` flags.
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.1.0
|
||||
=====
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.1.1
|
||||
=====
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.1.2
|
||||
=====
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.3.2
|
||||
=====
|
||||
|
||||
|
@ -34,7 +33,3 @@ image size can lead to a smaller allocation than expected, leading to
|
|||
arbitrary writes.
|
||||
|
||||
This issue was found by Cris Neckar at Divergent Security.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -23,17 +23,17 @@ redirected to the olefile package. Direct accesses to
|
|||
``PIL.OlefileIO`` raises a deprecation warning, then patches the
|
||||
upstream olefile into ``sys.modules`` in its place.
|
||||
|
||||
SGI image save
|
||||
SGI image save
|
||||
==============
|
||||
|
||||
It is now possible to save images in modes ``L``, ``RGB``, and
|
||||
``RGBA`` to the uncompressed SGI image format.
|
||||
``RGBA`` to the uncompressed SGI image format.
|
||||
|
||||
Zero sized images
|
||||
=================
|
||||
|
||||
Pillow 3.4.0 removed support for creating images with (0,0) size. This
|
||||
has been reenabled, restoring pre 3.4 behavior.
|
||||
has been reenabled, restoring pre 3.4 behavior.
|
||||
|
||||
Internal handles_eof flag
|
||||
=========================
|
||||
|
@ -41,11 +41,11 @@ Internal handles_eof flag
|
|||
The ``handles_eof flag`` for decoding images has been removed, as there
|
||||
were no internal users of the flag. Anyone maintaining image decoders
|
||||
outside of the Pillow source tree should consider using the cleanup
|
||||
function pointers instead.
|
||||
function pointers instead.
|
||||
|
||||
Image.core.stretch removed
|
||||
==========================
|
||||
|
||||
The stretch function on the core image object has been removed. This
|
||||
used to be for enlarging the image, but has been aliased to resize
|
||||
recently.
|
||||
recently.
|
||||
|
|
|
@ -12,7 +12,7 @@ Several deprecated items have been removed.
|
|||
|
||||
* The methods :py:meth:`PIL.ImageDraw.ImageDraw.setink`,
|
||||
:py:meth:`PIL.ImageDraw.ImageDraw.setfill`, and
|
||||
:py:meth:`PIL.ImageDraw.ImageDraw.setfont` have been removed.
|
||||
:py:meth:`PIL.ImageDraw.ImageDraw.setfont` have been removed.
|
||||
|
||||
|
||||
Closing Files When Opening Images
|
||||
|
@ -27,7 +27,7 @@ is specified:
|
|||
responsibility of the calling code to close the file.
|
||||
|
||||
* For images where Pillow opens the file and the file is known to have
|
||||
only one frame, the file is closed after loading.
|
||||
only one frame, the file is closed after loading.
|
||||
|
||||
* If the file has more than one frame, or if it can't be determined,
|
||||
then the file is left open to permit seeking to subsequent
|
||||
|
@ -36,7 +36,7 @@ is specified:
|
|||
|
||||
* If the image is memory mapped, then we can't close the mapping to
|
||||
the underlying file until we are done with the image. The mapping
|
||||
will be closed in the ``close`` or ``__del__`` method.
|
||||
will be closed in the ``close`` or ``__del__`` method.
|
||||
|
||||
|
||||
Changes to GIF Handling When Saving
|
||||
|
@ -50,7 +50,7 @@ saving images. There are two external changes that arise from this:
|
|||
|
||||
* The image to be saved is no longer modified in place by any of the
|
||||
operations of the save function. Previously it was modified when
|
||||
optimizing the image palette.
|
||||
optimizing the image palette.
|
||||
|
||||
This refactor fixed some bugs with palette handling when saving
|
||||
multiple frame GIFs.
|
||||
|
@ -60,7 +60,7 @@ New Method: Image.remap_palette
|
|||
|
||||
The method :py:meth:`PIL.Image.Image.remap_palette()` has been
|
||||
added. This method was hoisted from the GifImagePlugin code used to
|
||||
optimize the palette.
|
||||
optimize the palette.
|
||||
|
||||
Added Decoder Registry and Support for Python Based Decoders
|
||||
============================================================
|
||||
|
@ -76,7 +76,7 @@ Tests
|
|||
=====
|
||||
|
||||
Many tests have been added, including correctness tests for image
|
||||
formats that have been previously untested.
|
||||
formats that have been previously untested.
|
||||
|
||||
We are now running automated tests in Docker containers against more
|
||||
Linux versions than are provided on Travis CI, which is currently
|
||||
|
|
|
@ -20,5 +20,3 @@ CPython 3.6.1 to not work on installations of C-Python 3.6.0. This fix
|
|||
undefines PySlice_GetIndicesEx if it exists to restore compatibility
|
||||
with both 3.6.0 and 3.6.1. See https://bugs.python.org/issue29943 for
|
||||
more details.
|
||||
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ Fixed Windows PyPy Build
|
|||
|
||||
A change in the 4.2.0 cycle broke the Windows PyPy build. This has
|
||||
been fixed, and PyPy is now part of the Windows CI matrix.
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ TIFF Metadata Changes
|
|||
single element tuple. This is only with the new api, not the legacy
|
||||
api. This normalizes the handling of fields, so that the metadata
|
||||
with inferred or image specified counts are handled the same as
|
||||
metadata with count specified in the TIFF spec.
|
||||
metadata with count specified in the TIFF spec.
|
||||
* The ``PhotoshopInfo``, ``XMP``, and ``JPEGTables`` tags now have a
|
||||
defined type (bytes) and a count of 1.
|
||||
* The ``ImageJMetaDataByteCounts`` tag now has an arbitrary number of
|
||||
|
@ -85,7 +85,7 @@ There is a new :py:class:`PIL.ImageFilter.MultibandFilter` base class
|
|||
for image filters that can run on all channels of an image in one
|
||||
operation. The original :py:class:`PIL.ImageFilter.Filter` class
|
||||
remains for image filters that can process only single band images, or
|
||||
require splitting of channels prior to filtering.
|
||||
require splitting of channels prior to filtering.
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
@ -109,7 +109,7 @@ images to and from RGB and RGBA formats. The image data is truncated
|
|||
to 8-bit precision.
|
||||
|
||||
Pillow can now read RLE encoded SGI images in both 8 and 16-bit
|
||||
precision.
|
||||
precision.
|
||||
|
||||
Performance
|
||||
^^^^^^^^^^^
|
||||
|
@ -124,7 +124,7 @@ This release contains several performance improvements:
|
|||
* ``Image.transpose`` has been accelerated 15% or more by using a cache
|
||||
friendly algorithm.
|
||||
* ImageFilters based on Kernel convolution are significantly faster
|
||||
due to the new MultibandFilter feature.
|
||||
due to the new MultibandFilter feature.
|
||||
* All memory allocation for images is now done in blocks, rather than
|
||||
falling back to an allocation for each scan line for images larger
|
||||
than the block size.
|
||||
|
|
|
@ -80,4 +80,3 @@ ImagingSavePPM(Imaging im, const char* outfile)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -344,4 +344,3 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel,
|
|||
ImagingSectionLeave(&cookie);
|
||||
return imOut;
|
||||
}
|
||||
|
||||
|
|
|
@ -312,4 +312,3 @@ int ImagingJpegDecodeCleanup(ImagingCodecState state){
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,4 +39,3 @@ ImagingNegative(Imaging im)
|
|||
|
||||
return imOut;
|
||||
}
|
||||
|
||||
|
|
|
@ -188,4 +188,3 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ normalize_coeffs_8bpc(int outSize, int ksize, double *prekk)
|
|||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
ImagingResampleHorizontal_8bpc(Imaging imOut, Imaging imIn, int offset,
|
||||
int ksize, int *bounds, double *prekk)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ static void read4B(UINT32* dest, UINT8* buf)
|
|||
static int expandrow(UINT8* dest, UINT8* src, int n, int z)
|
||||
{
|
||||
UINT8 pixel, count;
|
||||
|
||||
|
||||
for (;n > 0; n--)
|
||||
{
|
||||
pixel = *src++;
|
||||
|
@ -42,7 +42,7 @@ static int expandrow(UINT8* dest, UINT8* src, int n, int z)
|
|||
*dest = *src++;
|
||||
dest += z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
pixel = *src++;
|
||||
|
@ -51,7 +51,7 @@ static int expandrow(UINT8* dest, UINT8* src, int n, int z)
|
|||
dest += z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static int expandrow2(UINT16* dest, UINT16* src, int n, int z)
|
|||
{
|
||||
UINT8 pixel, count;
|
||||
|
||||
|
||||
|
||||
for (;n > 0; n--)
|
||||
{
|
||||
pixel = ((UINT8*)src)[1];
|
||||
|
@ -96,7 +96,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
|||
SGISTATE *c;
|
||||
int err = 0;
|
||||
|
||||
/* Get all data from File descriptor */
|
||||
/* Get all data from File descriptor */
|
||||
c = (SGISTATE*)state->context;
|
||||
_imaging_seek_pyFd(state->fd, 0L, SEEK_END);
|
||||
c->bufsize = _imaging_tell_pyFd(state->fd);
|
||||
|
@ -155,7 +155,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
|||
c->rleoffset = c->starttab[c->rowno + c->channo * im->ysize];
|
||||
c->rlelength = c->lengthtab[c->rowno + c->channo * im->ysize];
|
||||
c->rleoffset -= SGI_HEADER_SIZE;
|
||||
|
||||
|
||||
/* row decompression */
|
||||
if (c->bpc ==1) {
|
||||
if(expandrow(&state->buffer[c->channo], &ptr[c->rleoffset], c->rlelength, im->bands))
|
||||
|
@ -165,19 +165,19 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
|||
if(expandrow2((UINT16*)&state->buffer[c->channo * 2], (UINT16*)&ptr[c->rleoffset], c->rlelength, im->bands))
|
||||
goto sgi_finish_decode;
|
||||
}
|
||||
|
||||
|
||||
state->count += c->rlelength;
|
||||
}
|
||||
|
||||
|
||||
/* store decompressed data in image */
|
||||
state->shuffle((UINT8*)im->image[state->y], state->buffer, im->xsize);
|
||||
|
||||
|
||||
}
|
||||
|
||||
c->bufsize++;
|
||||
|
||||
sgi_finish_decode: ;
|
||||
|
||||
|
||||
free(c->starttab);
|
||||
free(c->lengthtab);
|
||||
free(ptr);
|
||||
|
|
|
@ -490,7 +490,7 @@ ImagingAllocateBlock(Imaging im)
|
|||
im->image[y] = im->block + i;
|
||||
i += im->linesize;
|
||||
}
|
||||
|
||||
|
||||
im->destroy = ImagingDestroyBlock;
|
||||
|
||||
return im;
|
||||
|
|
|
@ -188,7 +188,7 @@ unpack1IR(UINT8* out, const UINT8* in, int pixels)
|
|||
static void
|
||||
unpack18(UINT8* out, const UINT8* in, int pixels)
|
||||
{
|
||||
/* Unpack a '|b1' image, which is a numpy boolean.
|
||||
/* Unpack a '|b1' image, which is a numpy boolean.
|
||||
1 == true, 0==false, in bytes */
|
||||
|
||||
int i;
|
||||
|
|
1
map.c
1
map.c
|
@ -385,4 +385,3 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
|||
|
||||
return PyImagingNew(im);
|
||||
}
|
||||
|
||||
|
|
1
path.c
1
path.c
|
@ -625,4 +625,3 @@ static PyTypeObject PyPathType = {
|
|||
0, /*tp_members*/
|
||||
getsetters, /*tp_getset*/
|
||||
};
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
Quick README
|
||||
------------
|
||||
------------
|
||||
|
||||
For more extensive info, see the windows build instructions `docs/build.rst`.
|
||||
|
||||
* See https://github.com/python-pillow/Pillow/issues/553#issuecomment-37877416 and https://github.com/matplotlib/matplotlib/issues/1717#issuecomment-13343859
|
||||
* See https://github.com/python-pillow/Pillow/issues/553#issuecomment-37877416 and https://github.com/matplotlib/matplotlib/issues/1717#issuecomment-13343859
|
||||
|
||||
* Works best with Python 3.4, due to virtualenv and pip batteries included. Python3+ required for fetch command.
|
||||
* Check config.py for virtual env paths, suffix for 64-bit releases. Defaults to `x64`, set `X64_EXT` to change.
|
||||
|
|
|
@ -76,7 +76,7 @@ def build_one(py_ver, compiler):
|
|||
args['executable'] = "python.exe"
|
||||
if 'EXECUTABLE' in os.environ:
|
||||
args['executable'] = "%EXECUTABLE%"
|
||||
|
||||
|
||||
args['py_ver'] = py_ver
|
||||
if '34' in py_ver:
|
||||
args['tcl_ver'] = '86'
|
||||
|
|
|
@ -91,4 +91,3 @@ Testing Pillow
|
|||
|
||||
Build and install Pillow, then run `python test.py` from the
|
||||
`winbuild` directory.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user