Guest User

Untitled

a guest
Jun 22nd, 2018
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Merge multi GIF pictures into one GIF.
  4.  
  5. requirement:
  6. pip install boxx>=0.9.1
  7.  
  8. @author: DIYer22@github
  9. """
  10.  
  11.  
  12.  
  13. gif_paths = ['loga','show','tree',] # the gif paths without `.gif`
  14. fps = 24
  15. spatial_down_sample = 1
  16. time_down_sample = 1
  17.  
  18.  
  19. from boxx import *
  20. from boxx.ylimg.ylimgVideoAndGif import *
  21.  
  22.  
  23. a=0
  24. a=1
  25. if a:
  26. gifs = []
  27. for pp in gif_paths:
  28. gif = imread(pp+'.gif')[::]
  29. gifs += [gif]
  30. # break
  31. ss = npa(map(x_.shape, gifs))
  32. print(ss)
  33. #else:
  34. fs = ss[:,0]
  35. shape = ss.max(0)[[1, 2]]
  36. news = []
  37. for i,gif in enumerate(gifs):
  38. n , w, h, c = gif.shape
  39. print('%sth GIF has'%i,n,'pics')
  40. new = np.zeros((n, *shape, c), np.uint8)
  41. new[:,:w,:h,:] = gif
  42. news.extend(new)
  43. news.extend(np.zeros((3, *shape, c), np.uint8))
  44. newgif = npa-news
  45. print('save to merged_one.gif....')
  46. gifSave(newgif[::time_down_sample,::spatial_down_sample,::spatial_down_sample,::],'merged_one.gif',fps)
  47. print('OK')
Add Comment
Please, Sign In to add comment