gify icon indicating copy to clipboard operation
gify copied to clipboard

Can someone explain to me how to use this?

Open forrestblade opened this issue 6 years ago • 1 comments

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

forrestblade avatar Jul 23 '18 19:07 forrestblade

  1. Download gify.jsjdataview.js to local.
  2. Use copy-webpack-plugin to copy static files to the output directory when building.
  3. Import gify.jsjdataview.js with <script> on index.html. (<script src="./assets/js/gify.min.js"></script>)
  4. 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)
  })
}

toFrankie avatar Dec 29 '22 09:12 toFrankie