Skip to content

Commit

Permalink
Fixes #506 - Image order when setting Sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Nov 18, 2020
1 parent d9d6205 commit 910619d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Version 0.6.4
Unreleased.

- Fixed `MagickFloatType` mapping for **s390x** architecture. [:issue:`504` & :issue:`505`]
- Fixed image order when calling :meth:`wand.sequence.Sequence.__setitem__()` method. [:issue:`506`]
- Added :meth:`Image.color_threshold() <wand.image.BaseImage.color_threshold>` method.
- Added :meth:`Image.convex_hull() <wand.image.BaseImage.convex_hull>` method. Requires ImageMagick-7.0.10 or above.
- Added :meth:`Image.kmeans() <wand.image.BaseImage.kmeans>` method. Only available with ImageMagick-7.0.10-37 or later.
Expand Down
8 changes: 6 additions & 2 deletions wand/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ def __setitem__(self, index, image):
raise TypeError('image must be an instance of wand.image.'
'BaseImage, not ' + repr(image))
with self.index_context(index) as index:
library.MagickRemoveImage(self.image.wand)
library.MagickAddImage(self.image.wand, image.wand)
if library.MagickHasNextImage(self.image.wand):
library.MagickAddImage(self.image.wand, image.wand)
library.MagickRemoveImage(self.image.wand)
else:
library.MagickRemoveImage(self.image.wand)
library.MagickAddImage(self.image.wand, image.wand)

def __delitem__(self, index):
if isinstance(index, slice):
Expand Down

0 comments on commit 910619d

Please sign in to comment.