0

I want to create Thumbnail component to play gif from url. Before playing, I would like to use snapshot about the gif. Is it possible or is there any way to take snapshot of played gif?

My example component :

 import React, { useState, useEffect } from 'react'
            
  interface IProps {
      thumbnailPlayUrl: string;
  }
            
  export default function Thumbnail({ thumbnailPlayUrl }: IProps) {
  const [status, setstatus] = useState("stop")
            
  useEffect(() => {}, [])
            
  return (
                   
       <div onMouseLeave={() => setstatus("stop")}>
            
             <div  className="static" style={status == "play" ? {} : { display: "none" }} >
    
                     <img src={thumbnailPlayUrl} alt={thumbnailPlayUrl} />
    
             </div>
            
            
             <div  style={status == "play" ? { display: "none" } : {}} onMouseOver={() => setstatus("play")}>
                {/*
                   <img 
                    src={require("../../assets/images/video-play-icon-2.png")}  <---- Example with play icon 
                    alt={thumbnailSnapshotUrl} />
                 */}
    
                    <img 
                    src={"exampleThumbnailSnapshotUrl"} {/* <----- I want snapshot url here like .jpg , .png about */}
                    alt={"exampleThumbnailSnapshotUrl"} /> 
             </div>
            
       </div>
            
                   
                )
            }
evolutionxbox
  • 3,932
  • 6
  • 34
  • 51
Emre Sert
  • 318
  • 6
  • 19
  • Are you using typescript? – evolutionxbox May 11 '21 at 09:25
  • yes. I am using it. – Emre Sert May 11 '21 at 09:26
  • You may want to use [libgif-js](https://github.com/buzzfeed/libgif-js) to get a particular frame of the gif (or all of the frames). Find some related info at [this question](https://stackoverflow.com/questions/4645274/extracting-single-frames-from-an-animated-gif-to-canvas). ......... (Or if you want to first extract all the frames manually -- ie, not programatically -- and store them somewhere for use as separate images, [this tool](https://onlinegiftools.com/extract-gif-frames) claims to provide that functionality.) – Cat May 11 '21 at 10:42

0 Answers0