[IOS] GIF animation with Pythonista3. I was addicted to it.

Introduction

There are many apps for making GIF animations, but since I have ** Pythonista3 **, I decided to make it myself while referring to the articles of many seniors.

Immediately addicted

I had made a GIF animation with ** Python ** on ** Win10 ** before, so I wrote it with ** PIL ** based on that memory, but only the first image is saved. Was not done.

testGIF.py


w,h = 100,100
images = []

for c in range(0,256,8):
  img = Image.new('RGB',(w,h),(c,c,c))
  images.append(img)

images += reversed(images)

SaveName = 'test.gif'
images[0].save(SaveName,
             save_all=True,
             append_images=images[1:],
             optimize=False,
             duration=20,
             loop=0)

I did a lot of research, but in the end I was able to confirm the operation on win10, so I concluded that ** PIL on iOS does not work **.

Its name is "images2gif"

While researching, I had a similar question and found out about the existence of "images2gif". It's a module name that is exactly what I wanted to do.

It was also featured in the official documentation and was installed from the beginning.

-Pythonista Module — Python 3.6.1 Documentation

How to use "images2gif"

Basically, the following description seems to be fine.

writeGif( SaveName, ImageList, duration=0.1,repeat=True)

testGIF2.py


from PIL import Image
from images2gif import writeGif

w,h = 100,100
images = []

for c in range(0,256,8):
  img = Image.new('RGB',(w,h),(c,c,c))
  images.append(img)

images += reversed(images)

SaveName = 'test.gif'
writeGif( SaveName, images, duration=0.02,repeat=True)

test.gif

Python GIF art

Japanese help

The last thing that surprised me was that the Japanese help article I was looking for was ** "I posted it myself before" **, and I thought it was finally dangerous.

Recommended Posts

[IOS] GIF animation with Pythonista3. I was addicted to it.
[IOS] Disassemble GIF animation with Pythonista3.
[Introduction to json] No, I was addicted to it. .. .. ♬
Use Python from Java with Jython. I was also addicted to it.
I was addicted to scraping with Selenium (+ Python) in 2020
I was addicted to multiprocessing + psycopg2
What I was addicted to with json.dumps in Python base64 encoding
A note I was addicted to when creating a table with SQLAlchemy
I was addicted to pip install mysqlclient
I was addicted to Flask on dotCloud
Add images to iOS photos with Pythonista
What I was addicted to Python autorun
I want to tweet on Twitter with Python, but I'm addicted to it
I was addicted to running tensorflow on GPU with NVIDIA driver 440 + CUDA 10.2
I was addicted to creating a Python venv environment with VS Code
A story I was addicted to trying to get a video url with tweepy
I was addicted to trying Cython with PyCharm, so make a note
The file edited with vim was readonly but I want to save it
Three things I was addicted to when using Python and MySQL with Docker
I was able to mock AWS-Batch with python, moto, so I will leave it
Docker x visualization didn't work and I was addicted to it, so I summarized it!
A note I was addicted to when running Python with Visual Studio Code
A story that I was addicted to when I made SFTP communication with python
I set up TensowFlow and was addicted to it, so make a note
A story that I was addicted to at np.where
I was able to repeat it in Python: lambda
I was addicted to trying logging.getLogger in Flask 1.1.x
What I was addicted to when using Python tornado
What I did when I was angry to put it in with the enable-shared option
A beginner tried coloring line art with chainer. I was able to do it.
I was able to implement web app authentication with flask-login
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
When I try to push with heroku, it doesn't work
What I was addicted to when dealing with huge files in a Linux 32bit environment
Since there was a doppelganger, I tried to distinguish it with artificial intelligence (laugh) (Part 2)
What I was addicted to when migrating Processing users to Python
PyTorch's book was difficult to understand, so I supplemented it
I made an animation to return Othello stones with POV-Ray
There was a doppelganger, so I tried to distinguish it with artificial intelligence (laughs) (Part 1)
[Fixed] I was addicted to alphanumeric judgment of Python strings
Note that I was addicted to accessing the DB with Python's mysql.connector using a web application.
I was addicted to not being able to get an email address from google with django-allauth authentication
When I put Django in my home directory, I was addicted to static files with permission errors
A story that I was addicted to calling Lambda from AWS Lambda.
The record I was addicted to when putting MeCab on Heroku
A memorandum when I tried to get it automatically with selenium
What I was addicted to when introducing ALE to Vim for Python
A note I was addicted to when making a beep on Linux
Note that I was addicted to sklearn's missing value interpolation (Imputer)
I tried to summarize what was output with Qiita with Word cloud
[Introduction to Matplotlib] Axes 3D animation: I played with 3D Lissajous figures ♬
I was addicted to confusing class variables and instance variables in Python
I want to do ○○ with Pandas
It was with Nintendo's Code Puzzle
I want to debug with Python
Easy animation with matplotlib (mp4, gif)
[Python] When I tried to make a decompression tool with a zip file I just knew, I was addicted to sys.exit ()
Even if I converted jpg to png, I managed to do it because the transparency was not tampered with
Two things I was addicted to building Django + Apache + Nginx on Windows
I want to do it with Python lambda Django, but I will stop
When I tried to run Python, it was skipped to the Microsoft Store