Skip to content

Commit

Permalink
Merge pull request #4685 from Meithal/patch-3
Browse files Browse the repository at this point in the history
Correctly read JPEG compressed BLP images
  • Loading branch information
hugovk committed Feb 19, 2022
2 parents e5fa767 + 58509a4 commit 3d33987
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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 @@ -392,9 +392,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

0 comments on commit 3d33987

Please sign in to comment.