note 82912 deleted from function.imagecreatefromgif by kalle
| From: | kalle@php.net | Date: | Fri, 22 Mar 2013 19:21:59 +0000 |
| Subject: | note 82912 deleted from function.imagecreatefromgif by kalle | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194179@lists.php.net to get a copy of this message | ||
Note Submitter: max lloyd
----
Someone wanted to display only the first frame of an animated .gif
I thought maybe if the animated .gif was displayed
as a .png, it would only display the first frame.
This worked very good:
The HTML used to display image:
<img src="giftopng.php?image=mypic.gif" alt="" />
The test script called: "giftopng.php"
<?php
//Get image name from URL
$image=$_GET['image'];
//Load the image
$img = ImageCreateFromGif($image);
//Convert to PNG and send it to browser
if($img) {
header("Content-Type: image/png");
ImagePNG($img);
//Clean-up memory
ImageDestroy($img);
}
?>