GIF slideshow maker
-
a fun little script to build slideshows as animated gifs.
''' Simplest GIF Slideshow based on "Simplest CSS Slideshow" http://snook.ca/archives/html_and_css/simplest-css-slideshow ''' def fadeImgs(img1, img2, seconds, fps=30): frames = int(seconds * fps) duration = 1 / fps w, h = imageSize(img1) for i in range(frames): newPage(w, h) frameDuration(duration) alpha1 = i * 1.0 / (frames - 1) alpha2 = 1.0 - alpha1 image(img1, (0, 0), alpha=alpha2) image(img2, (0, 0), alpha=alpha1) def makeSlideshow(imgs, static, fade, gifPath, resolution): w, h = imageSize(imgs[0]) for i, img in enumerate(imgs): newPage(w, h) frameDuration(static) image(img, (0, 0)) nextImg = imgs[(i + 1) % len(imgs)] fadeImgs(img, nextImg, fade) saveImage(gifPath, imageResolution=resolution) imgs = [ "https://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg", "https://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg", "https://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg", ] makeSlideshow(imgs, 2, 1, '~/Desktop/slideshow-test.gif', 18)