簡體   English   中英

在php代碼中顯示圖像變量

[英]display image variable in php code

我正在嘗試從php中的變量顯示圖像。 遵循了這個問題,但我得到了這個而不是圖像

PNG IHDRBMyAPLTE ٟ IDAT c Z8Y] Ðf T% IEND B IEND.B

這是我的代碼。

$tt_image = imagecreate( 100, 50 ); /* width, height */
$background = imagecolorallocatealpha( $tt_image, 0, 0, 255, 127 ); /* In RGB colors- (Red, Green, Blue, Transparency ) */
header( "Content-type: image/png" );
imagepng( $tt_image );
imagecolordeallocate( $background );
imagedestroy( $tt_image );

該代碼已檢查並發現有效。 在顯示之前,您必須編輯圖像。 並將標題放在顯示圖像的上方。

    $tt_image = imagecreate( 100, 100 ); /* width, height */
$background = imagecolorallocatealpha( $tt_image, 0, 0, 255, 78 );  //fill some color
header ('Content-type: image/png'); //image type header
imagepng($tt_image, NULL, 0);       //disply image
imagedestroy($tt_image);            //destroy image

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM