gify
gify copied to clipboard
Can someone explain to me how to use this?
How do I pass in a gif url to find the duration of the gif in a new create-react-app.
Any help would be greatly appreciated
- Download
gify.js
、jdataview.js
to local. - Use
copy-webpack-plugin
to copy static files to theoutput
directory when building. - Import
gify.js
、jdataview.js
with<script>
onindex.html
. (<script src="./assets/js/gify.min.js"></script>
) - When ready, see the
example.html
in the repo for usage 👉 here. Or 👇
const getGifInfo = async file => {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onload = event => {
const URL = window.URL || window.webkitURL
const blob = new Blob([event.target.result])
const blobURL = URL.createObjectURL(blob)
const img = new Image()
img.src = blobURL
img.onload = () => {
const gifInfo = window.gify.getInfo(reader.result)
resolve(gifInfo)
}
img.onerror = event => {
reject(event)
}
}
reader.readAsArrayBuffer(file)
})
}