超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<imagecreatefrompngimagecreatefromwbmp>
Last updated: Fri, 22 Jun 2007

imagecreatefromstring

(PHP 4 >= 4.0.4, PHP 5)

imagecreatefromstring -- 从字符串中的图像流新建一图像

说明

resource imagecreatefromstring ( string image)

imagecreatefromstring() 返回一图像标识符,代表了从给定的字符串中取得的图像。




add a note add a note User Contributed Notes
imagecreatefromstring
adrian_schmidt at yahoo dot com
06-Mar-2003 08:04
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);

<imagecreatefrompngimagecreatefromwbmp>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22