Skip to content

Commit

Permalink
Added Image.remove_image to match add_image method
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Jul 30, 2021
1 parent f5310fd commit d3980a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Expand Up @@ -15,6 +15,7 @@ Version 0.6.7
Unreleased.

- Added :meth:`Image.add_image() <wand.image.Image.add_image>` method.
- Added :meth:`Image.remove_image() <wand.image.Image.remove_image>` method.
- Fixed sub-image extraction on read. [:issue:`532`]
- [DOC] Completed :doc:`Distortion <./guide/distortion>` guide. [:issue:`534`]

Expand Down
6 changes: 6 additions & 0 deletions tests/image_test.py
Expand Up @@ -249,6 +249,12 @@ def test_ping_from_file(fx_asset):
assert img.size == (402, 599)


def test_remove_image():
with Image(filename='null:') as empty:
empty.remove_image()
assert empty.iterator_length() == 0


def test_save_to_filename(fx_asset):
"""Saves an image to the filename."""
savefile = os.path.join(tempfile.mkdtemp(), 'savetest.jpg')
Expand Down
8 changes: 8 additions & 0 deletions wand/image.py
Expand Up @@ -9758,6 +9758,14 @@ def read(self, file=None, filename=None, blob=None, background=None,
if units is not None:
self.units = units

@trap_exception
def remove_image(self):
"""Remove an image from the image-stack at the current index.
.. versionadded:: 0.6.7
"""
return library.MagickRemoveImage(self.wand)

def reset_sequence(self):
"""Remove any previously allocated :class:`~wand.sequence.SingleImage`
instances in :attr:`sequence` attribute.
Expand Down

0 comments on commit d3980a0

Please sign in to comment.