Merge pull request #4685 from Meithal/patch-3

Correctly read JPEG compressed BLP images
This commit is contained in:
Hugo van Kemenade 2022-02-19 11:03:36 +02:00 committed by GitHub
commit 3d33987d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -5,6 +5,11 @@ from PIL import BlpImagePlugin, Image
from .helper import assert_image_equal_tofile
def test_load_blp1():
with Image.open("Tests/images/blp/blp1_jpeg.blp") as im:
assert_image_equal_tofile(im, "Tests/images/blp/blp1_jpeg.png")
def test_load_blp2_raw():
with Image.open("Tests/images/blp/blp2_raw.blp") as im:
assert_image_equal_tofile(im, "Tests/images/blp/blp2_raw.png")

View File

@ -392,9 +392,9 @@ class BLP1Decoder(_BLPBaseDecoder):
data = BytesIO(data)
image = JpegImageFile(data)
Image._decompression_bomb_check(image.size)
self.tile = image.tile # :/
self.fd = image.fp
self.mode = image.mode
image.mode = "RGB"
image.tile = [("jpeg", (0, 0) + self.size, 0, ("BGRX", ""))]
self.set_as_raw(image.tobytes())
class BLP2Decoder(_BLPBaseDecoder):