PHP判断一个gif图片是否为动态图片(动画)的方法

WBOY
Release: 2016-06-20 13:04:19
Original
1140 people have browsed it

如何使用PHP来判断一个gif图片是否为动态图片(动画)?

首先想到的是使用getimagesize()函数来看type值,发现都是gif,所以这个办法是不可行的。

下面是作者在网上看到的一个函数,用来判断gif是否为动图的。贴出来和大家分享。

<span style="font-size: 14px;">/*</span><br /> * 判断图片是否为动态图片(动画)<br /> */<br />function isAnimatedGif($filename) {<br />$fp=fopen($filename,'rb');<br />$filecontent=fread($fp,filesize($filename));<br />fclose($fp);<br />return strpos($filecontent,chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0')===FALSE?0:1;<br />}
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!