openzoom / deepzoom.py

Python Deep Zoom Tools
http://openzoom.org/
Other
176 stars 74 forks source link

ValueError: image has wrong mode #22

Closed mbaechtold closed 2 years ago

mbaechtold commented 3 years ago

When I try to generate a DZI from the file available at https://www.sendspace.com/file/yskm3h, I get the exception ValueError: image has wrong mode:

from deepzoom import ImageCreator
creator = ImageCreator()
source = "/path/to/image"
destination = "/path/to/dzi"
creator.create(source=source, destination=destination)

Here's the traceback:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-9003b8af8c39> in <module>
----> 1 creator.create(source=input, destination=output)

~/path/to/virtualenv/src/deepzoomtools/deepzoom/__init__.py in create(self, source, destination)
    424         for level in range(self.descriptor.num_levels):
    425             level_dir = _get_or_create_path(os.path.join(image_files, str(level)))
--> 426             level_image = self.get_image(level)
    427             for (column, row) in self.tiles(level):
    428                 bounds = self.descriptor.get_tile_bounds(level, column, row)

~/path/to/virtualenv/src/deepzoomtools/deepzoom/__init__.py in get_image(self, level)
    399             return self.image
    400         if (self.resize_filter is None) or (self.resize_filter not in RESIZE_FILTERS):
--> 401             return self.image.resize((width, height), PIL.Image.ANTIALIAS)
    402         return self.image.resize((width, height), RESIZE_FILTERS[self.resize_filter])
    403

~/path/to/virtualenv/lib/python3.9/site-packages/PIL/Image.py in resize(self, size, resample, box, reducing_gap)
   1927                 )
   1928
-> 1929         return self._new(self.im.resize(size, resample, box))
   1930
   1931     def reduce(self, factor, box=None):

ValueError: image has wrong mode

Do you have an idea why this happening?

mbaechtold commented 2 years ago

The calling code should handle such errors. So I'm closing this issue.