【发布时间】:2013-12-31 00:11:09
【问题描述】:
我正在尝试从外部站点上的 .php 文件中提取图像,该文件是 gif(一帧)。我想最后将这些图像放入 gif 中,但目前这不是问题。每次我尝试将 gif 保存为 .pngs 时,它都会返回错误“不是有效的 GIF 文件”
include('GIFEncoder.class.php');
$user = $_GET['user'];
$url = 'http://link.com/image.php?username=' . $user . '';
$username = explode('=', $url);
$username = $username[1];
$img = 'image_cache/' . $username .'.gif';
file_put_contents($img, file_get_contents($url));
$i = imagecreatefromgif('image_cache/' . $username . '.gif');
imagepng($i, "image_cache/". $username .".png");
我得到的确切错误
警告:imagecreatefromgif() [function.imagecreatefromgif]: 'image_cache/Lexo.gif' 不是第 9 行 z/projects/gif/index.php 中的有效 GIF 文件
【问题讨论】:
-
错误不是告诉你问题是什么吗?
-
外部gif的url是什么?
-
为什么你认为它会在你的脚本中返回一个 GIF?
-
gif 在那里,我可以在 FTP 上看到它,它可以工作。外部 php im 抓取 gif 链接是 game.habboon.com/habbo-imaging/… - gif 在那里,但它说它不是“有效的”。
标签: php image file-get-contents