New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotating page in multipage TIFF breakes page order #506
Comments
Hey, Thanks for posting it. I can reproduce this, and it looks like a bug. Here's a workaround until I can get around to fixing it. from wand.image import Image
with Image(filename='two_page.tif') as image:
image.iterator_set(0)
image.rotate(90)
image.save(filename='output.tif') |
Thanks for confirming. I was debugging the library a bit more and found that this patch can also fix my problem. Unfortunately I don't understand why, but maybe it will help.
|
Under the hood, the image stack is just a linked list. I'm guessing the diff --git a/wand/sequence.py b/wand/sequence.py
index 939da52..f3d5f27 100644
--- a/wand/sequence.py
+++ b/wand/sequence.py
@@ -140,8 +140,8 @@ class Sequence(ImageProperty, abc.MutableSequence):
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)
+ library.MagickRemoveImage(self.image.wand)
def __delitem__(self, index):
if isinstance(index, slice):
|
Hmm. needs more research. Both patches will not work when editing the last image on the stack. However it looks like the current code was written in 2013, and ImageMagick changed the behavior in 2016. |
Ah! We just need to check if we're at the end of the list to determine removal order. This will be fixed with Wand-0.6.4 |
Hi, I'm rotating the first page of a two-page TIFF image with this code:
The page is rotated as intended, but the rotated (first) page is saved as second and the initially second page is saved as first. I can't attach the tiff files, but I'm adding two jpgs for easy reproduction. I created the multipage TIFF by calling
convert page_*.jpg -compress lzw two_page.tif
. Am I doing something wrong or is this a bug?Adding identify output for tiff files to be sure thats not only a bug in my viewer:
Adding also my env setup:
The text was updated successfully, but these errors were encountered: