mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-25 14:44:45 +03:00
Avoid potential draft artifacts by resizing
This commit is contained in:
parent
7bf5246b93
commit
daad220b55
|
@ -581,6 +581,11 @@ class TestFileJpeg(PillowTestCase):
|
|||
# OSError for unidentified image.
|
||||
self.assertEqual(im.info.get("dpi"), (72, 72))
|
||||
|
||||
def test_partial_mcu(self):
|
||||
im = Image.open("Tests/images/flower2.jpg")
|
||||
im.draft(im.mode, (100, 100))
|
||||
self.assertEqual(im.size, (100, 100))
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")
|
||||
class TestFileCloseW32(PillowTestCase):
|
||||
|
|
|
@ -396,6 +396,20 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
self.tile = [(d, e, o, a)]
|
||||
self.decoderconfig = (scale, 0)
|
||||
|
||||
if scale > 1:
|
||||
sampling = get_sampling(self)
|
||||
if sampling != -1:
|
||||
mcu = [(8, 8), (16, 8), (16, 16)][sampling]
|
||||
for i in range(0, 2):
|
||||
# If an original image dimension is not a whole number of
|
||||
# MCUs, then the additional data may not be correct.
|
||||
if self.size[i] % mcu[i] != 0:
|
||||
im = self.resize(size)
|
||||
|
||||
self.im = im.im
|
||||
self._size = size
|
||||
break
|
||||
|
||||
return self
|
||||
|
||||
def load_djpeg(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user