diff --git a/imagick/magick_wand_image.go b/imagick/magick_wand_image.go index 75009ea..ced987e 100644 --- a/imagick/magick_wand_image.go +++ b/imagick/magick_wand_image.go @@ -475,15 +475,14 @@ func (mw *MagickWand) CropImageToTiles(cropGeom string) error { defer C.MagickDestroyImage(newImg) - newWand := NewMagickWandFromImage(&Image{newImg}) - defer newWand.Destroy() - - if err := mw.AddImage(newWand); err != nil { - return fmt.Errorf("error replacing image: %v", err) + for next := newImg; next != nil; next = C.GetNextImageInList(next) { + tempWand := NewMagickWandFromImage(&Image{next}) + if err := mw.AddImage(tempWand); err != nil { + return fmt.Errorf("error replacing image: %v", err) + } + tempWand.Destroy() } - - mw.PreviousImage() - + mw.SetFirstIterator() if err := mw.RemoveImage(); err != nil { return fmt.Errorf("error removing current image: %v", err) }