close

 

輸出 JPEG 圖像
<?php
// 創鍵空白圖像並添加一些文本
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);

// 設置內容類型標頭 —— 這個例子里是 image/jpeg
header('Content-Type: image/jpeg');

// 輸出圖像
imagejpeg($im);

// 釋放內存
imagedestroy($im);
?>


保存一副 JPEG 圖像
<?php
// 創鍵空白圖像並添加一些文本
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);

// 保存圖像為 'simpletext.jpg'
imagejpeg($im, 'simpletext.jpg');

// 釋放內存
imagedestroy($im);
?>

以 75% 的圖像質量輸出圖像
<?php
// 創鍵空白圖像並添加一些文本
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);

// 設置內容類型標頭 —— 這個例子里是 image/jpeg
header('Content-Type: image/jpeg');

// 使用 NULL 跳過 filename 參數,並設置圖像質量為 75%
imagejpeg($im, NULL, 75);

// 釋放內存
imagedestroy($im);
?>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 stockwfj3 的頭像
    stockwfj3

    程式設計@筆記

    stockwfj3 發表在 痞客邦 留言(0) 人氣()