pythondeepzoom

How may I create deep zoom file keeping a very large image (600k x 600k) file in google drive?


I am using deepzoom python API with the following code-

import os
import deepzoom
# Specify your source image
SOURCE = "https://drive.google.com/uc?export=view&id=1W5UKlO_wZJLNvqsyC0E3zJ5CVlSDp_PG"
DEST = "D:\\mesh.dzi"

# Create Deep Zoom Image creator with weird parameters
creator = deepzoom.ImageCreator(
tile_size=128,
tile_overlap=2,
tile_format="png",
image_quality=0.8,
resize_filter="bicubic",
)

# Create Deep Zoom image pyramid from source

creator.create(SOURCE, DEST)

Please note that I am using Windows 10 OS and Jupyter Notebook to run the code. But showing the following error-

---------------------------------------------------------------------------
UnidentifiedImageError                    Traceback (most recent call last)
<ipython-input-14-6b5c22482c62> in <module>
  1 # Create Deep Zoom image pyramid from source
----> 2 creator.create(SOURCE, DEST)

~\anaconda3\lib\site-packages\deepzoomtools-2.0.0a2-py3.8.egg\deepzoom\__init__.py in 
create(self, source, destination)
411     def create(self, source, destination):
412         """Creates Deep Zoom image from source file and saves it to destination."""
--> 413         self.image = PIL.Image.open(safe_open(source))
414         width, height = self.image.size
415         self.descriptor = DeepZoomImageDescriptor(

~\anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode, formats)
2941     for message in accept_warnings:
2942         warnings.warn(message)
-> 2943     raise UnidentifiedImageError(
2944         "cannot identify image file %r" % (filename if filename else fp)
2945     )

UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000001FE552ED9F0>

Solution

  • Try libvips instead. libvips has no problem dealing with large images.

    libvips documentation.