Skip to content

Commit

Permalink
Don’t deepcopy streams dicts when duplicating for interpolation
Browse files Browse the repository at this point in the history
Unsurprisingly, deepcopy doesn’t work well on SMask streams :).
  • Loading branch information
liZe committed Mar 13, 2023
1 parent ab6daa2 commit c7087d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions weasyprint/pdf/stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""PDF stream."""

import io
from copy import deepcopy
from functools import lru_cache
from hashlib import md5

Expand Down Expand Up @@ -370,9 +369,12 @@ def add_image(self, image, image_rendering):
return image_name

interpolate = 'true' if image_rendering == 'auto' else 'false'
extra = deepcopy(image.extra)
extra = image.extra.copy()
extra['Interpolate'] = interpolate
if 'SMask' in extra:
extra['SMask'] = pydyf.Stream(
extra['SMask'].stream.copy(), extra['SMask'].extra.copy(),
extra['SMask'].compress)
extra['SMask'].extra['Interpolate'] = interpolate

xobject = pydyf.Stream(image.stream, extra=extra)
Expand Down

0 comments on commit c7087d3

Please sign in to comment.