[IOS] Disassemble GIF animation with Pythonista3.

Introduction

Previously, I wrote Articles I was addicted to with GIF animation, but I was interested in ** disassembling GIF animation ** during my research at that time. just made it.

Disassemble GIF animation

This was made up of ** Image Sequence ** inside ** PIL **. By the way, I made it a specification to call from the shared sheet of iOS.

gif2png


import appex
import console
import photos
import tempfile
from PIL import Image
from PIL import ImageSequence

def main():
	if not appex.is_running_extension():
		console.hud_alert('Please execute from the shared sheet.',icon='error',duration=2)
		return

	FilePath = appex.get_image().filename
	if not FilePath:
		console.hud_alert('GIF image not found.',icon='error',duration=2)
		return

	gif = Image.open(FilePath)
	for i,img in enumerate(ImageSequence.Iterator(gif)):
		SaveName = tempfile.gettempdir()+'/tmp.png'
		img.save(SaveName)
		photos.create_image_asset(SaveName)

	console.hud_alert(str(i+1)+'I saved the image in the photo.', icon='success', duration=2)
	appex.finish()

if __name__ == '__main__':
	main()

Register and use ** Share Extension Shortcuts ** of ** Pythonista3 **. [IOS] Use shared sheet with Pythonista3. --Qiita

How to use

If ** Pythonista3 ** is installed, tap the ** Share Menu ** icon from the photo app etc. to display the ** Run Pythonista Script ** menu. Just tap here and tap the pre-registered script icon. 7C39C630-454F-48B3-924A-FF17ADFEFAAD.gif

Video operated on iPad

Recommended Posts

[IOS] Disassemble GIF animation with Pythonista3.
[IOS] GIF animation with Pythonista3. I was addicted to it.
Easy animation with matplotlib (mp4, gif)
Add images to iOS photos with Pythonista
[IOS] Use a shared sheet with Pythonista3.
Make a GIF animation with folder monitoring
Animation with matplotlib
Animation with matplotlib
[IOS] Change the display time for each frame of GIF animation in Pythonista3.
Display Matsuya coupon (QR code) with Pythonista for iOS
LGTM --Compose LGTM images with videos and photos and output GIF animation
Make a gif animation from a serial number file with matplotlib
Visualize cavity flow with matplotlib and save as gif animation
Create 3d gif with python3
Diffusion equation animation with NumPy
Bidirectional file transfer with Pythonista 3
Bubble sort with fluffy animation