mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
return chosen image mode and the box of the image
This commit is contained in:
parent
2d1482b400
commit
4126f6cdf7
|
@ -13,7 +13,11 @@ class TestImageDraft(PillowTestCase):
|
|||
im = Image.new(in_mode, in_size)
|
||||
data = tostring(im, "JPEG")
|
||||
im = fromstring(data)
|
||||
im.draft(req_mode, req_size)
|
||||
mode, box = im.draft(req_mode, req_size)
|
||||
scale, _ = im.decoderconfig
|
||||
self.assertEqual(box[:2], (0, 0))
|
||||
self.assertTrue((im.width - scale) < box[2] <= im.width)
|
||||
self.assertTrue((im.height - scale) < box[3] <= im.height)
|
||||
return im
|
||||
|
||||
def test_size(self):
|
||||
|
|
|
@ -1190,6 +1190,9 @@ class Image(object):
|
|||
JPEG to greyscale while loading it, or to extract a 128x192
|
||||
version from a PCD file.
|
||||
|
||||
If any changes are made, returns a tuple with the chosen `mode` and
|
||||
`box` with coordinates of the original image within the altered one.
|
||||
|
||||
Note that this method modifies the :py:class:`~PIL.Image.Image` object
|
||||
in place. If the image has already been loaded, this method has no
|
||||
effect.
|
||||
|
|
|
@ -416,6 +416,7 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
|
||||
d, e, o, a = self.tile[0]
|
||||
scale = 1
|
||||
original_size = self.size
|
||||
|
||||
if a[0] == "RGB" and mode in ["L", "YCbCr"]:
|
||||
self.mode = mode
|
||||
|
@ -438,7 +439,9 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
self.tile = [(d, e, o, a)]
|
||||
self.decoderconfig = (scale, 0)
|
||||
|
||||
return self
|
||||
box = (0, 0, original_size[0] / float(scale),
|
||||
original_size[1] / float(scale))
|
||||
return (self.mode, box)
|
||||
|
||||
def load_djpeg(self):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user