Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly read JPEG compressed BLP images #4685

Merged
merged 12 commits into from Feb 19, 2022
Binary file added Tests/images/blp/blp1_jpeg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Tests/test_file_blp.py
Expand Up @@ -5,6 +5,11 @@
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")
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/BlpImagePlugin.py
Expand Up @@ -357,9 +357,9 @@ def _decode_jpeg_stream(self):
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):
Expand Down