# Understand imageio.mimwrite() with Examples for Beginners- ImageIO Tutorial

By | October 25, 2019

imageio.mimwrite() can write multiple images to the specified file. However, the parameters in this function is not clear, in this tutorial, we will explain it with examples.

## Syntax

imageio.mimwrite(uri, ims, format=None, **kwargs)

Write multiple images to the specified file.

## Parameters explained

uri: a file name or file object. ImageIO will write some images into this file.

For example:

uri = r'e:\demo.gif'

ims: a list of image data. Each image data you can read by imageio.imread() function. For example:

data = imageio.imread('E:\\video-images\\1.jpg')

format:  the format of uri, it can be .png, .gif, .tif etc al.

Here is a detailed list:

**kwargs: this is the most important of this function.

As to .gif format, to save images to a gif image, you should know content of **kwargs.

imageio.help('.gif')

Then you will find these key parameters:

## Parameters on .gif format

loop : int
The number of iterations. Default 0 (meaning loop indefinitely).

duration : {float, list}
The duration (in seconds) of each frame. Either specify one value that is used for all frames, or one value for each frame.
Note that in the GIF format the duration/delay is expressed in hundredths of a second, which limits the precision of the duration.

fps : float
The number of frames per second. If duration is not given, the duration for each frame is set to 1/fps. Default 10.

palettesize : int
The number of colors to quantize the image to. Is rounded to the nearest power of two. Default 256.

subrectangles : bool
If True, will try and optimize the GIF by storing only the rectangular parts of each frame that change with respect to the previous. Default False.

Understanding parameters above, it is easy to use imageio.mimwrite().