我有这段代码可以生成此图片的一部分:My Minecraft skin (seriously, that is my image)
然而,它不会产生。图像无效。我的代码:
<?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 :(得分: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。