2013-08-06 57 views
-2

我已将此代码生成此图片的一部分:My Minecraft skin (seriously, that is my image)为什么这个php代码不会裁剪我的图像?

但是,它不生成。图像无效。我的代码:

<?php 
$username = "figgycity50"; 
$skin_php_data = file_get_contents ("http://s3.amazonaws.com/MinecraftSkins/".$username.".png"); 
$skin = imagecreatefrompng ($skin_php_data); 
$hv = array('x' => 8, 'y' => 8, 'width' => 8, 'height' => 8); 
$head = imagecrop($skin, $hv); 
header('Content-Type: image/png'); 
imagepng($head); 
?> 
+0

尝试:'的error_reporting(E_ALL | E_STRICT)' - 关:尖:http://stackoverflow.com/help/dont-ask http://stackoverflow.com/help/on-topic HTTP ://stackoverflow.com/help/deleted-questions –

回答

1

我认为你不应该使用的file_get_contents来。

<?php 
$username = "figgycity50"; 
$skin = imagecreatefrompng ("http://s3.amazonaws.com/MinecraftSkins/".$username.".png"); 
$hv = array('x' => 8, 'y' => 8, 'width' => 8, 'height' => 8); 
$head = imagecrop($skin, $hv); 
header('Content-Type: image/png'); 
imagepng($head); 
?> 

该文件声明imagecreatefrompng接受文件名作为其参数。如果启用了fopen包装,您可以使用URL。

http://ca1.php.net/imagecreatefrompng

+0

奇怪,但这不起作用。我检查了我的php.ini,打开了打包程序,它们正在运行。 – user2558132

+0

我试图加载你的图片,它似乎也是腐败。尝试其他图像。 – beiller

+0

@bellier ok。你有没有试过访问非裁剪图像? – user2558132