Try creating a Deep Zoom file format .DZI in Python

Regarding DZI, Microsoft has prepared it rather than explaining it to me. I think it's faster to see the page .

The idea is that the area that can be displayed on one screen even if the image is 100MB per image is about 1MB, so it is only necessary to divide it into 1000 and read only the display area. It's rough.

Isn't it more difficult to display a program than to create data? Those who think </ strong> are correct. I published it in another article " Try using a Google Maps-like open source high-resolution image viewer ". I made my own with ActionScript and CoffeeScript respectively, but I would like to introduce it at another time along with the sad background that I did not know the DZI format.

Let's get back to DZI. The tool for creating DZI files is already made in Python , so download it and try it out.

Please refer to the README for how to install PIL.

The contents of the sample program are so simple that it is not necessary to explain it. Take a look at examples / helloworld / helloworld.py.

!/usr/bin/env python
 -*- coding: utf-8 -*-

import deepzoom

 Specify your source image
SOURCE = "helloworld.jpg "

 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, "helloworld.dzi")

It's almost okay if you change the input image and the output image ... Let's check the options of ImageCreater for the time being.

Here, according to the notation of OpenZoom , the image divided into squares is called a "tile".

tile_size How many px should the image be divided vertically and horizontally? DZI tiles are basically square.

tile_overlap This is faster if you look at the image.

2932771418_82ceddfa0b.jpg

If you divide the tiles without margins (what should I call them) and arrange them, you may get flicker. To prevent this, the option to split larger than tile_size is called tile overlap.

tile_format Read this as it is. This time, it is output as png, but it can also be output as jpg.

image_quality This is also the same. Image quality specification. 1 is the upper limit.

resize_filter I'm too specialized in this and I don't know everything, but if you want to know more, please see below. http://www.dfx.co.jp/dftalk/?p=13061

If you are not particular about it, bicubic is fine.

There are other detailed arrangements, so if you would like to know more, please see below. http://www.openzoom.org/

Now, after specifying the options, input image, and output file name, just tap

$ python helloworld.py

You should now have a DZI file and a filename_images directory in the same directory.

The viewer will be explained in " Try using a Google Maps-like open source high-resolution image viewer ".

Thank you for your support.

Recommended Posts

Try creating a Deep Zoom file format .DZI in Python
Try creating a compressed file using Python and zlib
Create a binary file in Python
Schedule a Zoom meeting in Python
Creating a simple PowerPoint file with Python
Try sending a SYN packet in Python
Try drawing a simple animation in Python
[GPS] Create a kml file in Python
Try a functional programming pipe in Python
format in python
Create a GIF file using Pillow in Python
Try to calculate a statistical problem in Python
Ubuntu18.04.05 Creating a python virtual environment in LTS
Read a file containing garbled lines in Python
How to create a JSON file in Python
Create a Photoshop format file (.psd) with python
Create a MIDI file in Python using pretty_midi
File processing in Python
Image format in Python
File operations in Python
Try gRPC in Python
Try 9 slices in Python
Parse a JSON string written to a file in Python
Try to make a Python module in C language
Try searching for a million character profile in Python
Try embedding Python in a C ++ program with pybind11
A memorandum to run a python script in a bat file
I want to randomly sample a file in Python
Run a Python file with relative import in PyCharm
Take a screenshot in Python
Try running python in a Django environment created with pipenv
Easily format JSON in Python
Create a function in Python
Create a dictionary in Python
Download the file in Python
Change the standard output destination to a file in Python
Get the MIME type in Python and determine the file format
How to import a file anywhere you like in Python
Try creating a CRUD function
A memo when creating a directed graph using Graphviz in Python
Try LINE Notify in Python
[Note] Import of a file in the parent directory in Python
Make a bookmarklet in Python
Try building a neural network in Python without using a library
Try implementing Yubaba in Python 3
Draw a heart in Python
Try running a function written in Python using Fn Project
Just try to receive a webhook in ngrok and python
Try to get a list of breaking news threads in Python.
[Python / Django] Create a web API that responds in JSON format
Read a file in Python with a relative path from the program
Python vba to create a date string for creating a file name
Get the formula in an excel file as a string in Python
[ROS2] How to play a bag file with python format launch
Try adding a wall to your IFC file with IfcOpenShell python
Maybe in a python (original title: Maybe in Python)
Count specific strings in a file
Write a binary search in Python
File / folder path manipulation in Python
[python] Manage functions in a list
Hit a command in Python (Windows)