Topic: Avatar - Animated GIF
How to accept gif only, but not animated gif for avatar? If not, is there a way to keep only the first frame before saving the file to the avatar directory? Thanks.
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 discussion → Avatar - Animated GIF
How to accept gif only, but not animated gif for avatar? If not, is there a way to keep only the first frame before saving the file to the avatar directory? Thanks.
I found this in the PHP doc comments
function is_ani($filename)
{
$filecontents=file_get_contents($filename);
$str_loc=0;
$count=0;
while ($count < 2) # There is no point in continuing after we find a 2nd frame
{
$where1=strpos($filecontents,"\x00\x21\xF9\x04",$str_loc);
if ($where1 === FALSE)
{
break;
}
else
{
$str_loc=$where1+1;
$where2=strpos($filecontents,"\x00\x2C",$str_loc);
if ($where2 === FALSE)
{
break;
}
else
{
if ($where1+8 == $where2)
{
$count++;
}
$str_loc=$where2+1;
}
}
}
if ($count > 1)
{
return(true);
}
else
{
return(false);
}
}
Thank you!
How to incorporate this into the viewtopic.php?
Is this a possible option to convert the gif to jpg format upon uploading the avatar? From then on, it would be treated as a jpg and not a gif file. How?
You would incorporate the function I gave you into profile.php. Then, you could reject animated GIFs.
As for converting from GIF to JPG, it's certainly possible using the GD library
PunBB Forums → PunBB 1.2 discussion → Avatar - Animated GIF
Powered by PunBB, supported by Informer Technologies, Inc.