Skip to content

Commit

Permalink
Merge branch 'master' into tiff-jpeg-quality
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jun 25, 2019
2 parents b0a17b5 + ea570a8 commit a18a371
Show file tree
Hide file tree
Showing 211 changed files with 6,043 additions and 4,683 deletions.
23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/ISSUE_REPORT.md
@@ -0,0 +1,59 @@
---
name: Issue report
about: Create a report to help us improve Pillow
---

<!--
Thank you for reporting an issue.
Follow these guidelines to ensure your issue is handled properly.
If you have a ...
1. General question: consider asking the question on Stack Overflow
with the python-imaging-library tag:
* https://stackoverflow.com/questions/tagged/python-imaging-library
Do not ask a question in both places.
If you think you have found a bug or have an unexplained exception
then file a bug report here.
2. Bug report: include a self-contained, copy-pastable example that
generates the issue if possible. Be concise with code posted.
Guidelines on how to provide a good bug report:
* https://stackoverflow.com/help/mcve
Bug reports which follow these guidelines are easier to diagnose,
and are often handled much more quickly.
3. Feature request: do a quick search of existing issues
to make sure this has not been asked before.
We know asking good questions takes effort, and we appreciate your time.
Thank you.
-->

### What did you do?

### What did you expect to happen?

### What actually happened?

### What are your OS, Python and Pillow versions?

* OS:
* Python:
* Pillow:

<!--
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.
-->

```python
code goes here
```
24 changes: 24 additions & 0 deletions CHANGES.rst
Expand Up @@ -5,6 +5,30 @@ Changelog (Pillow)
6.1.0 (unreleased)
------------------

- Fixed bugs in calculating text size #3864
[radarhere]

- Add __main__.py to output basic format and support information #3870
[jdufresne]

- Added variation font support #3802
[radarhere]

- Do not down-convert if image is LA when showing with PNG format #3869
[radarhere]

- Improve handling of PSD frames #3759
[radarhere]

- Improved ICO and ICNS loading #3897
[radarhere]

- Changed Preview application path so that it is no longer static #3896
[radarhere]

- Corrected ttb text positioning #3856
[radarhere]

- Handle unexpected ICO image sizes #3836
[radarhere]

Expand Down
4 changes: 2 additions & 2 deletions Tests/32bit_segfault_check.py
Expand Up @@ -4,5 +4,5 @@
import sys


if sys.maxsize < 2**32:
im = Image.new('L', (999999, 999999), 0)
if sys.maxsize < 2 ** 32:
im = Image.new("L", (999999, 999999), 0)
27 changes: 15 additions & 12 deletions Tests/bench_cffi_access.py
Expand Up @@ -26,18 +26,21 @@ def timer(func, label, *args):
starttime = time.time()
for x in range(iterations):
func(*args)
if time.time()-starttime > 10:
print("%s: breaking at %s iterations, %.6f per iteration" % (
label, x+1, (time.time()-starttime)/(x+1.0)))
if time.time() - starttime > 10:
print(
"%s: breaking at %s iterations, %.6f per iteration"
% (label, x + 1, (time.time() - starttime) / (x + 1.0))
)
break
if x == iterations-1:
if x == iterations - 1:
endtime = time.time()
print("%s: %.4f s %.6f per iteration" % (
label, endtime-starttime, (endtime-starttime)/(x+1.0)))
print(
"%s: %.4f s %.6f per iteration"
% (label, endtime - starttime, (endtime - starttime) / (x + 1.0))
)


class BenchCffiAccess(PillowTestCase):

def test_direct(self):
im = hopper()
im.load()
Expand All @@ -48,11 +51,11 @@ def test_direct(self):
self.assertEqual(caccess[(0, 0)], access[(0, 0)])

print("Size: %sx%s" % im.size)
timer(iterate_get, 'PyAccess - get', im.size, access)
timer(iterate_set, 'PyAccess - set', im.size, access)
timer(iterate_get, 'C-api - get', im.size, caccess)
timer(iterate_set, 'C-api - set', im.size, caccess)
timer(iterate_get, "PyAccess - get", im.size, access)
timer(iterate_set, "PyAccess - set", im.size, access)
timer(iterate_get, "C-api - get", im.size, caccess)
timer(iterate_set, "C-api - set", im.size, caccess)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions Tests/bench_get.py
Expand Up @@ -2,6 +2,7 @@
import timeit

import sys

sys.path.insert(0, ".")


Expand Down
2 changes: 1 addition & 1 deletion Tests/check_fli_overflow.py
Expand Up @@ -12,5 +12,5 @@ def test_fli_overflow(self):
im.load()


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
5 changes: 2 additions & 3 deletions Tests/check_icns_dos.py
Expand Up @@ -6,7 +6,6 @@
from io import BytesIO

if py3:
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00',
'latin-1')))
Image.open(BytesIO(bytes("icns\x00\x00\x00\x10hang\x00\x00\x00\x00", "latin-1")))
else:
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00')))
Image.open(BytesIO(bytes("icns\x00\x00\x00\x10hang\x00\x00\x00\x00")))
24 changes: 13 additions & 11 deletions Tests/check_imaging_leaks.py
Expand Up @@ -9,11 +9,11 @@
max_iterations = 10000


@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or macOS")
@unittest.skipIf(sys.platform.startswith("win32"), "requires Unix or macOS")
class TestImagingLeaks(PillowTestCase):

def _get_mem_usage(self):
from resource import getpagesize, getrusage, RUSAGE_SELF

mem = getrusage(RUSAGE_SELF).ru_maxrss
return mem * getpagesize() / 1024 / 1024

Expand All @@ -25,20 +25,22 @@ def _test_leak(self, min_iterations, max_iterations, fn, *args, **kwargs):
if i < min_iterations:
mem_limit = mem + 1
continue
msg = 'memory usage limit exceeded after %d iterations' % (i + 1)
msg = "memory usage limit exceeded after %d iterations" % (i + 1)
self.assertLessEqual(mem, mem_limit, msg)

def test_leak_putdata(self):
im = Image.new('RGB', (25, 25))
self._test_leak(min_iterations, max_iterations,
im.putdata, im.getdata())
im = Image.new("RGB", (25, 25))
self._test_leak(min_iterations, max_iterations, im.putdata, im.getdata())

def test_leak_getlist(self):
im = Image.new('P', (25, 25))
self._test_leak(min_iterations, max_iterations,
# Pass a new list at each iteration.
lambda: im.point(range(256)))
im = Image.new("P", (25, 25))
self._test_leak(
min_iterations,
max_iterations,
# Pass a new list at each iteration.
lambda: im.point(range(256)),
)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
16 changes: 11 additions & 5 deletions Tests/check_j2k_dos.py
Expand Up @@ -6,10 +6,16 @@
from io import BytesIO

if py3:
Image.open(BytesIO(bytes(
'\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang',
'latin-1')))
Image.open(
BytesIO(
bytes(
"\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang",
"latin-1",
)
)
)

else:
Image.open(BytesIO(bytes(
'\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang')))
Image.open(
BytesIO(bytes("\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang"))
)
14 changes: 8 additions & 6 deletions Tests/check_j2k_leaks.py
Expand Up @@ -4,21 +4,22 @@
from io import BytesIO

# Limits for testing the leak
mem_limit = 1024*1048576
stack_size = 8*1048576
iterations = int((mem_limit/stack_size)*2)
mem_limit = 1024 * 1048576
stack_size = 8 * 1048576
iterations = int((mem_limit / stack_size) * 2)
codecs = dir(Image.core)
test_file = "Tests/images/rgb_trns_ycbc.jp2"


@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or macOS")
@unittest.skipIf(sys.platform.startswith("win32"), "requires Unix or macOS")
class TestJpegLeaks(PillowTestCase):
def setUp(self):
if "jpeg2k_encoder" not in codecs or "jpeg2k_decoder" not in codecs:
self.skipTest('JPEG 2000 support not available')
self.skipTest("JPEG 2000 support not available")

def test_leak_load(self):
from resource import setrlimit, RLIMIT_AS, RLIMIT_STACK

setrlimit(RLIMIT_STACK, (stack_size, stack_size))
setrlimit(RLIMIT_AS, (mem_limit, mem_limit))
for _ in range(iterations):
Expand All @@ -27,6 +28,7 @@ def test_leak_load(self):

def test_leak_save(self):
from resource import setrlimit, RLIMIT_AS, RLIMIT_STACK

setrlimit(RLIMIT_STACK, (stack_size, stack_size))
setrlimit(RLIMIT_AS, (mem_limit, mem_limit))
for _ in range(iterations):
Expand All @@ -38,5 +40,5 @@ def test_leak_save(self):
test_output.read()


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
6 changes: 3 additions & 3 deletions Tests/check_j2k_overflow.py
Expand Up @@ -5,11 +5,11 @@
class TestJ2kEncodeOverflow(PillowTestCase):
def test_j2k_overflow(self):

im = Image.new('RGBA', (1024, 131584))
target = self.tempfile('temp.jpc')
im = Image.new("RGBA", (1024, 131584))
target = self.tempfile("temp.jpc")
with self.assertRaises(IOError):
im.save(target)


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

0 comments on commit a18a371

Please sign in to comment.