Introduction:

Hey! Hello, I’m Kimiko! Today we bring you a fun Python small program, hope you like 💗, remember to pay attention ~

Are there any forms of content that are smaller than mini videos and richer than regular pictures ????

* *! * * ✨

Gifs are one such form, and they are essential.

GIF should have been filled with the Internet, by everyone to play, we can not accept the pure text in the article or static pictures, these have long been unable to table

Here’s what you’re thinking. Only a dynamic diagram can express the primordial power of the body. 💨 💨

Ha ha ha, today’s words to douluo mainland as an example, teach you to make a few different character style GIF!

(words this country diffuse everybody should have seen ha, crazy chase after diffuse – is the update te slow! Amway, although slow but also has more than 100 episodes, can go to Kangkang ~)

The body of the

💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙

He would have given his life for her, killed himself and removed the bone.She could burn her life for him, sacrifice the ring.

— Tang Jia SAN Shao, Douluo Continent

A simple GIF production

1) In preparation

1.1 The environment involved in simple GIF production is as follows:

Python3, Pycharm, Pillow modules.

Module installation:

PIP install + module name or PIP install -i https://pypi.douban.com/simple/ + module nameCopy the code

1.2 Preparing Materials

Group 1: Dance 3 pictures.

Group 2: ning Rongrong 8 pictures.

2) Brief introduction

PIL’s most important class is Image and you can load images from files, or work with other images, or create them from Scratch.

To load an Image from a file through the open() function of the Image module.

3) Code demonstration

A GIF is a sequence of open images. (Effect dynamic video is put at the bottom)

Source code base: #959755565# CSDN PIL import Image im = image.open ("1.jpg") images = [] image.append (image.open ('2.jpg')) images.append(Image.open('3.jpg')) ....... Im.save ('gif. GIF ', save_all=True, append_images=images, loop=1, duration=1, comment=b"aaabb")Copy the code

Two, upgrade imageio GIF production

1) In preparation

1.1 The environment involved in simple GIF production is as follows:

Python3, Pycharm, Imageio modules.

Module installation:

PIP install + module name or PIP install -i https://pypi.douban.com/simple/ + module nameCopy the code

1.2 Preparing Materials

Group 1: dance 30 pictures.

Group 2: zhu Zhuqing Dai Mubai 37 pictures.

2) Brief introduction

IMAIO is a Python library that provides a simple interface to read and write large amounts of image data, including animated images, volume data, and scientific formats. It is a

Cross-platform, running Python 2. x and 3. X, and easy to install.

Imageio.imread () # Reads the image from the specified file. Returns a NUMPY array with metadata meta-attributes.

Note that image data is returned as is and may not always have the dType of uTI8 (thus may differ from, for example, PIL return).

3) Code demonstration

First read the static image into the list as each frame of the GIF; Then set the input (static image), output (dynamic image) and some necessary parameters. Here we set the interval of each frame to xx seconds, the default is 1 second, and then call miageio. Mimsave function to save the result. (Effect dynamic video is put at the bottom)

Source code base: #959755565# CSDN Import imageio def create_gif(image_list, gif_name, duration = 1.0): "" :param image_list: This list is used to store images that generate giFs :param GIF_name: string, filename of GIF generated, with. GIF suffix :param duration: time between images :return: ''' frames = [] for image_name in image_list: frames.append(imageio.imread(image_name)) imageio.mimsave(gif_name, frames, 'GIF', duration=duration) return def main(): # image_list = ['xx', 'xx', Duration = xx # duration = xx # create_gif(image_list, gif_name, duration) if __name__ == '__main__': main()Copy the code

Iii. General effect display

​​

💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙 💙

conclusion

Every tip deserves to be taken seriously! I hope it helps.

​​

🎯 Full free source code pick-up:

For complete project source code + source material base see: # private letter xiaobian 06# or click on the blue text to add you can get free benefits!

Past recommendation —

Item 1.0 Fireworks rose (with multiple source codes)

Python code: “Starry night fireworks are yours, I also belong to you” (fireworks in full bloom, with roses)

Project 1.1 Love Guide (including multiple source code)

You can’t find someone to love. You can’t find someone to love.

Project 1.0 flying snow small program

Python applets: You see? The most beautiful snow in a thousand years

Item 3.2 Automatic Wallpaper change

Your computer automatically changes your wallpaper every day. This is for you.

🍓 Article summary —

The article summary | Python 1.0-2021 | has continuously updated, direct look at this article is enough

More content + source code in the article summary oh!! Welcome to read ~)