感謝您抽出時間。像許多其他人一樣,我是PHP的新手。在這個腳本的第一部分(注意//作品)我已經從文件中加載了一些名字到一個URL中以顯示我想要的圖像。這樣可行。現在我需要幫助調整大小和自動裁剪所有這些圖片。請看看這個腳本,看看你是否看到我應該做的不同。在腳本中調整大小/裁剪幾張圖像
<?php
$file = 'serverlist.txt'; // works
$servers = ''; // works
$imgheight = 200; // ??
$imgwidth = 200; // ??
if ($handle = fopen($file, 'r')) { // works
while (!feof($handle)) { // works
$content = trim(fgets($handle)); // works
$names = explode(' ', $content); // works
foreach ($names as $name) { // works
$servers .= '<img src="http://minecraft.net/skin/' . $name. '.png" alt="">'; //works.
}
foreach ($servers as $imgservers) { // ?
$skin = imagecreatefrompng($imgservers); // ?
$face = imagecreatetruecolor($width, $height); // ?
imagecopyresized($face, $skin, 0, 0, 8, 8, $width, $height, 8, 8); // ?
imagecopyresized($face, $skin, 0, 0, 40, 8, $width, $height, 8, 8); // ?
}
}
fclose($handle); // works
}
?>
<html>
<head>
</head>
<body>
<?php
imagepng($face); // ?
?>
</body>
</html>
所以我應該做'foreach'裏面'如果'與'$服務器'? – user2176480 2013-03-16 21:15:31
查看['imagepng()'](http://www.php.net/manual/en/function.imagepng.php)的文檔。它「將PNG圖像輸出到瀏覽器或文件」。您需要等待調用'imagepng()',直到您獲得'
'標籤。 – Aiias 2013-03-16 21:21:08我更新了代碼。仍然不給我我期待的結果。我做了另一個foreach,我不知道如果我應該。 – user2176480 2013-03-16 21:33:11