Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can someone explain to me how to use this? #6

Open
forrestblade opened this issue Jul 23, 2018 · 1 comment
Open

Can someone explain to me how to use this? #6

forrestblade opened this issue Jul 23, 2018 · 1 comment

Comments

@forrestblade
Copy link

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

@toFrankie
Copy link
Contributor

  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)
  })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants