當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP imagegammacorrect()用法及代碼示例

imagegammacorrect()函數是PHP中的內置函數,用於在給定輸入和輸出伽馬的情況下對給定圖像應用伽馬校正。

用法:

bool imagegammacorrect( resource $image, float $inputgamma, float $outputgamma )

參數:此函數接受上述和以下所述的三個參數:


  • $image:它指定要處理的圖像。
  • $inputgamma:它指定輸入伽瑪。
  • $outputgamma:它指定輸出伽瑪。

返回值:如果成功,則此函數返回TRUE;如果失敗,則返回FALSE。

異常:該函數在出錯時引發Exception。

下麵給出的程序說明了PHP中的imagegammacorrect()函數:程序1:

<?php 
// Create an image 
$im = imagecreatefrompng('https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); 
  
// Change the image gamma 
imagegammacorrect($im, 3, 1.3); 
  
// Output to browser 
header('Content-Type:image/png'); 
imagepng($im); 
imagedestroy($im); 
?>

輸出:

程序2:

<?php 
// Create an empty image 
$im = imagecreatetruecolor(800, 250); 
  
// Set the background to be light blue 
imagefilledrectangle($im, 0, 0, 800, 250, imagecolorallocate($im, 0, 0, 180)); 
  
// Add text using a font from local 
imagefttext($im, 80, 0, 50, 130, imagecolorallocate($im, 0, 150, 0), './Pacifico.ttf', 'GeeksforGeeks'); 
  
// Change the image gamma 
imagegammacorrect($im, 3, 1.3); 
  
// Output to browser 
header('Content-Type:image/png'); 
imagepng($im); 
imagedestroy($im); 
?>

輸出:

參考: https://www.php.net/manual/en/function.imagegammacorrect.php



相關用法


注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | imagegammacorrect() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。