Skip to content

Commit

Permalink
Allow None argument for Image.write_mask. Fixes #636
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Nov 2, 2023
1 parent f74eb51 commit a60dd66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Unreleased.

- Fixed behavior when passing zero to :meth:`Image.chop() <wand.image.BaseImage.chop>`. [:issue:`622`]
- Fixed `libmagick` yield `MagickCore` library on Linux. [:issue:`612`]
- Fixed removing mask when passing :const:`None` to :meth:`Image.write_mask() <wand.image.BaseImage.write_mask>` method. [:issue:`636`]
- Added new :const:`COMPOSITE_OPERATORS <wand.image.COMPOSITE_OPERATORS>` operators. [:issue:`627` by druzhynin-oleksii]

- ``'freeze'``
Expand Down
6 changes: 5 additions & 1 deletion wand/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9200,7 +9200,11 @@ def write_mask(self, clip_mask=None):
raise WandLibraryVersionError('Method requires ImageMagick-7.')
else: # pragma: no cover
if clip_mask is None:
r = library.MagickSetImageMask(self.wand, WritePixelMask, None)
w, h = self.size
with Image(width=w, height=h, pseudo='xc:none') as clear:
r = library.MagickSetImageMask(self.wand,
WritePixelMask,
clear.wand)
elif isinstance(clip_mask, BaseImage):
r = library.MagickSetImageMask(self.wand, WritePixelMask,
clip_mask.wand)
Expand Down

0 comments on commit a60dd66

Please sign in to comment.