Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 2, 2022
1 parent d822d85 commit e9f4858
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Tests/test_file_jpeg.py
Expand Up @@ -93,11 +93,11 @@ def test_com_write(self):
with BytesIO() as buf:
im.save(buf, format="JPEG")
with Image.open(buf) as im2:
assert im.app['COM'] == im2.app['COM']
assert im.app["COM"] == im2.app["COM"]
with BytesIO() as buf:
im.save(buf, format="JPEG", comment=dummy_text)
with Image.open(buf) as im2:
assert im2.app['COM'].decode() == dummy_text
assert im2.app["COM"].decode() == dummy_text

def test_cmyk(self):
# Test CMYK handling. Thanks to Tim and Charlie for test data,
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/JpegImagePlugin.py
Expand Up @@ -44,8 +44,8 @@
from . import Image, ImageFile, TiffImagePlugin
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o16be as o16
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .JpegPresets import presets

Expand Down Expand Up @@ -716,12 +716,12 @@ def validate_qtables(qtables):

comment = info.get("comment")
if comment is None and isinstance(im, JpegImageFile):
comment = im.app.get('COM')
comment = im.app.get("COM")
if comment:
if isinstance(comment, str):
comment = comment.encode()
size = o16(2 + len(comment))
extra += b'\xFF\xFE%s%s' % (size, comment)
extra += b"\xFF\xFE%s%s" % (size, comment)

icc_profile = info.get("icc_profile")
if icc_profile:
Expand Down

0 comments on commit e9f4858

Please sign in to comment.