All Projects → CaptainCodeman → gif-player

CaptainCodeman / gif-player

Licence: MIT license
Control your animated GIFs

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to gif-player

sail
The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software
Stars: ✭ 206 (+71.67%)
Mutual labels:  gif, gif-animation
TTFancyGifDialog-Android
TTFancyGifDialog makes your Android Dialog Fancy and more Beautiful. A library that makes normal Android Dialog to high level Dialog with many styling options and fully customizable. Make dialog from few lines of code.
Stars: ✭ 61 (-49.17%)
Mutual labels:  gif, gif-animation
drawer
A touch-enabled drawer component for the modern web.
Stars: ✭ 26 (-78.33%)
Mutual labels:  custom-element, webcomponent
KGySoft.Drawing
KGy SOFT Drawing is a library for advanced image, icon and graphics handling.
Stars: ✭ 27 (-77.5%)
Mutual labels:  gif, gif-animation
AGMobileGiftInterface
simplified interaction with GIF animations
Stars: ✭ 40 (-66.67%)
Mutual labels:  gif, gif-animation
Gifski
🌈 Convert videos to high-quality GIFs on your Mac
Stars: ✭ 5,691 (+4642.5%)
Mutual labels:  gif, gif-animation
makesweet
Put pictures into animations from the command line.
Stars: ✭ 18 (-85%)
Mutual labels:  gif, gif-animation
glips
screen clip to gif on web
Stars: ✭ 18 (-85%)
Mutual labels:  gif, gif-animation
imagor
Fast, Docker-ready image processing server in Go and libvips
Stars: ✭ 2,276 (+1796.67%)
Mutual labels:  gif, gif-animation
cast2gif
Tool to render Asciinema cast files to GIFs, *without* using Electron or a web browser. Written in Rust.
Stars: ✭ 23 (-80.83%)
Mutual labels:  gif, gif-animation
Gifski
GIF encoder based on libimagequant (pngquant). Squeezes maximum possible quality from the awful GIF format.
Stars: ✭ 2,417 (+1914.17%)
Mutual labels:  gif, gif-animation
xvcode
web dynamic validation code generator 动态web校验码图片生成
Stars: ✭ 43 (-64.17%)
Mutual labels:  gif
smart-custom-element
Smart a lightweight web component library that provides capabilities for web components, such as data binding, using es6 native class inheritance. This library is focused for providing the developer the ability to write robust and native web components without the need of dependencies and an overhead of a framework.
Stars: ✭ 17 (-85.83%)
Mutual labels:  custom-element
iOSUtilitiesSource
IOS Utilities Library for Swift
Stars: ✭ 46 (-61.67%)
Mutual labels:  gif
record-desktop
🎥 Effortless GIFs and screenshots on Linux, built with Electron.
Stars: ✭ 65 (-45.83%)
Mutual labels:  gif
ios-nd-gif-maker-swift
Resources for Udacity's Gif Maker app in Swift.
Stars: ✭ 13 (-89.17%)
Mutual labels:  gif
kap-imgur
Kap plugin - Share GIFs on Imgur
Stars: ✭ 20 (-83.33%)
Mutual labels:  gif
godot-gdgifexporter
Gif exporter for Godot made entirely in GDScript
Stars: ✭ 85 (-29.17%)
Mutual labels:  gif
OpticalIllusions
Some Python code to reproduce a nice optical illusion found on the web.
Stars: ✭ 16 (-86.67%)
Mutual labels:  gif
gantt-chart
Web component implementation of a Gantt chart.
Stars: ✭ 24 (-80%)
Mutual labels:  webcomponent

Published on webcomponents.org

Published on Vaadin  Directory Stars on vaadin.com/directory

<gif-player>

WebComponent to control Animated GIF playback and access individual frames.

More demos

Move your mouse over the images ...

<gif-player src="https://media.giphy.com/media/TN0GTccRi7Ixa/giphy.gif" speed="0.5" play></gif-player>
<gif-player src="https://media.giphy.com/media/nh5QMbO89SFTG/giphy.gif" size="contain" prerender style="width:300px;height:200px"></gif-player>

This was inspired by x-gif but designed to work with the latest WebComponents v1 spec and fix some issues with playback of certain gifs. It uses the excellent GifReader from omggif for decoding.

Features:

  • Pure v1 WebComponent, approximately 4.5Kb gzipped
  • In-built (simple) loading spinner (because some GIFs are large)
  • Auto-start playback on load or pause at any frame relative to the start or end
  • Control playback speed relative to original GIF settings
  • Control frame displayed by mouseover / touch (based on horizontal position across the image)
  • Pre-render frames in idle time* (even if animation is not playing)

Due to the way animated gifs are encoded and rendered, it's not always possible to jump directly to a specific frame to display it - some of the image may be transparent and rely on pixels from previous frames to render correctly (called 'disposal' in the GIF spec). So if we want to render the last frame in the image, we may need to render all the previous ones first. The pre-rendering option allows this to happen in browser idle-time so that they are ready in advance (but is configurable). Frames are always automatically rendered as they are required during playback or UI interaction but there may be a slight delay depending on the size and complexity of the GIF.

Properties:

src="url" sets the source URL for the image, just like with the <img> element. DataURIs and regular URLs should work but the latter need to provide CORS headers if being used from a different domain. Imgur and Giphy both seem to work fine and are used in the demos.

size="auto" set to control the sizing. Options are auto (the control resizes to the size of the GIF image), cover or contain (as per object-fit or background-size CSS properties) or stretch to fill the control (may distort the GIF). The control must be explicitly sized for any option other than auto.

frame="0" set the frame to display relative to the start of the animation, use negative numbers to make the frame relative to the end, so frame="-1" would display the last frame.

play set to auto play the GIF on load

speed="2" set the playback speed relative to the original GIF encoding. A value of 0.5 would playback in slow-motion at half speed whereas 2 would double the speed for faster playback (will always depending on the performance capability of the client device).

repeat set to repeat playback on completion, otherwise stop

bounce set to reverse playback direction at the start or end of the animation rather than restarting.

direction="1" set the direction to play with 1 being forwards and -1 being reverse.

prerender set to use browser idle time to pre-render frames instead of rendering on demand.

Example, fit GIF in a 240 x 160 area, play it continually and reverse direction at either end:

<gif-player src="my.gif" size="contain" play bounce style="width: 240px; height: 160px;"></gif-player>

TODOs

It's not fully finished yet but it works pretty well for what I needed. Here are things I'm thinking should be added:

  • Alternative playback control - play / pause button to start & stop (or hold to play)
  • Use better rAF loop for rendering & timing of playback based on elapsed time.
  • Offload decoding work to service workers / offscreen canvas.
  • Fade-in images after loading and fade between frames to make display smoother.
  • Use IntersectionObserver to prevent playback while not on screen and also potentially unload some frames to reduce memory use.
  • Use streaming API to decode gif file as it loads so first frame can be displayed sooner.
  • Check disposal rules to determine exactly when retaining previous frame is required.
  • Make omggif a dependency and figure out how to make rollup remove the writer
  • Use css for cover / contain settings

Save decoded data so it isn't decompressed for every frame

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].