I need to convert animated GIF to static in PHP. I mean e.g. use its first frame. Any idea how to do that ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“Stripping” the GIF of animation can be done by converting it to another format and then back again. PNG is a good candidate for this “other format”, since it is non-lossy, unlike JPEG. Using PHPs GD functions, and outputting a PNG instead of a GIF:
This might work (haven’t tested) if PHP/GD doesn’t support animated GIFs (I don’t think it does); and it will output the image in GIF format, unlike the above snippet:
If that won’t work, and output in GIF format is essential, this will: