我想使用GD庫,似乎已安裝但我無法使用它。瀏覽器不顯示PNG圖像
我看看我的GD安裝與
php_info();
它返回我:
然後我嘗試這樣的:
<pre>
<?php print_r(gd_info())?>
</pre>
它返回這樣的:
Array
(
[GD Version] => bundled (2.0.34 compatible)
[FreeType Support] => 1
[FreeType Linkage] => with freetype
[T1Lib Support] => 1
[GIF Read Support] => 1
[GIF Create Support] => 1
[JPEG Support] => 1
[PNG Support] => 1
[WBMP Support] => 1
[XPM Support] =>
[XBM Support] => 1
[JIS-mapped Japanese Font Support] =>
)
但是當我嘗試做這樣的:
使用代碼:
<?php // content="text/plain; charset=utf-8"
$im = imagecreatetruecolor (300, 200);
$black = imagecolorallocate ($im, 0, 0, 0);
$lightgray = imagecolorallocate ($im, 230, 230, 230);
$darkgreen = imagecolorallocate ($im, 80, 140, 80);
$white = imagecolorallocate ($im, 255, 255, 255);
imagefilledrectangle ($im,0,0,299,199 ,$lightgray);
imagerectangle ($im,0,0,299,199,$black);
imagefilledellipse ($im,150,100,210,110,$white);
imagefilledellipse ($im,150,100,200,100,$darkgreen);
header ("Content-type: image/png");
imagepng ($im);
?>
它返回:
�PNG IHDR,�ݽK�IDATx������H���r,����p�CU�.!$Aw�ZB�h�].��ˀAM��O�5��D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�~F_����������7�)D��̎�s�"��po;,^�[email protected]�o�?���Y�N��覺�n~RM'������~�{���s� ��w� ���Z�\.їQƹ��&*ȍ�i�&��K��v��T�:>�����m�;K5.��}�u�#��T�W"�����nݫM����������K5���noOx�mr�Ǎpc~�;��GKq��䧽��R�8)���R��l��槽@Ok�;��#�_æ�s���h���p�@�%��bgv���1H��E�R���ZI����P~}�8�N"|T��:�(��N�T��8�G����Sx�oX=��P�#�l%�܄������k�Ò�P�\-�����b*�tX)B��z�e"T +JwX#B�T�D�@6*�a��K*v�=�{ d]� I��V��%���d^�y#T G�0i� ��*&�Ƒ1Bk���X�#��@��??�"LxPљl3�.���1�K>E�"�vDѫT��+��0 �lVbV���N��I�3)����f�E�V;lR,e� E�.#�I��A��ua{�a�bJO���Y���gR�b��f�G8�bf��7%����?h�����l�gR'��F�p�%Ŧ�Sm| �8��ƍp�1Ŧ���~p��f�Gx���&� ^z����]����Rlj������o&�e��8��}oU��W"|b_��� w�GL{�D�����fy�m��['���Te��6h�m$�C� ��鉾�����O�� ��A�4����N��b�M��t"|��I-���>@��8ͩ��[FZ����YN"�K3�(���P�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!�!����z�gt8IEND�B`�
是否有其他代碼在運行?嘗試將標題放在第一行... –
@HenriqueBarcelos沒有其他代碼在運行 – Wistar
看起來很好。你想在哪裏看圖片?在瀏覽器中? –