note 30080 added to function.imagecreatefromstring
| From: | adrian_schmidt at yahoo dot com | Date: | Wed, 05 Mar 2003 22:04:18 +0000 |
| Subject: | note 30080 added to function.imagecreatefromstring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44903@lists.php.net to get a copy of this message | ||
I'm trying to get the imagecreatefromstring to work with GIFs. Of course, it won't.
I've read the tips but can't get them to work either.
The following is what I tried, based on above tips:
---
header('Content-Type: image/gif');
header('Content-Disposition: inline; filename=file.gif');
$temp = tmpfile();
fwrite($temp, $line['image']);
$src_img = imagecreatefromgif($temp);
fclose($temp); // this removes the file
$dst_img = imagecreatetruecolor(100, 100);
imagecopyresampled($dst_img, $src_img, 0,0,0,0, 100,100, imagesx($src_img), imagesy($src_img));
imagegif($dst_img);
---
where $line['image'] is the gif as taken from my MySQL database...
If anyone that has been able to make something like this work could give me a working piece of code
I'd be really greatful!
I would be great if the tempfile could be excluded too...
Below is a working piece of code for jpeg:
---
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');
$src_img = imagecreatefromstring($line['image']);
$dst_img = imagecreatetruecolor(100, 100);
imagecopyresampled($dst_img, $src_img, 0,0,0,0, 100,100, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img);
--
http://www.php.net/manual/en/function.imagecreatefromstring.php
http://master.php.net/manage/user-notes.php?action=edit+30080
http://master.php.net/manage/user-notes.php?action=delete+30080
http://master.php.net/manage/user-notes.php?action=reject+30080