高さが再帰ツリーの深さに依存する画像を作成するスクリプトがあります。画像の高さを事前に計算するのは面倒です。再帰関数を2回実行する必要があるからです。したがって、私の唯一の再帰関数の内部から画像のサイズを変更することは可能かどうか疑問に思います。簡単に言うと、画像リソースのサイズを変更する必要がありますが、可能ですか?たとえば、次のコードを機能させるにはどうすればよいですか?ありがとう!
//Create the image
$image = imagecreatetruecolor(800, 100);
//Change the image height from 100 to 1000 pixels
imagecopyresized($image, $image, 0, 0, 0, 0, 800, 1000, 800, 100);
//Set the header
header('Content-Type: image/png');
//Output the image
imagepng($image);
//Destroy the image
imagedestroy($image);