34 lines
926 B
Python
34 lines
926 B
Python
import imageio
|
|
import os
|
|
import sys
|
|
import glob
|
|
|
|
def create_gif(source, name, duration):
|
|
"""
|
|
La función de generar gif, la imagen original solo supports png
|
|
fuente: lista de imágenes png (ordenadas)
|
|
nombre: el nombre del archivo generado
|
|
duración: el intervalo de tiempo entre cada imagen
|
|
"""
|
|
frames = [] # Leer en el búfer
|
|
for img in source:
|
|
frames.append(imageio.imread(img))
|
|
imageio.mimsave(name, frames, 'GIF', duration=duration)
|
|
print("Procesamiento completado")
|
|
|
|
|
|
path = "/home/mario/Documentos/Ocean/web2py/applications/BPP/views/default/maps2/"
|
|
pic_list =[]
|
|
cm="Spectral"
|
|
scenario="ssp370"
|
|
model="CanESM5"
|
|
Rut=path+"%s*%s*%s*.png"%(cm,scenario,model)
|
|
for name in glob.glob(Rut):
|
|
pic_list.append(name)
|
|
pic_list.sort()
|
|
gif_name = path+"Animated_%s_%s_%s.gif"%(cm,scenario,model)
|
|
print(gif_name)
|
|
duration_time = 0.5
|
|
|
|
|
|
create_gif(pic_list, gif_name, duration_time) |