グラデーション方法のサンプル how to create thumbnail + shadow by this script
/* offset of drop shadow from top left */ define ( "DS_OFFSET" , 5 ); /* number of steps from black to background color /* define("DS_STEPS", 10); /* distance between steps */ define ( "DS_SPREAD" , 1 ); /* define the background color */ $background = array( "r" => 255 , "g" => 255 , "b" => 255 ); // 元のサイズに対して、影のサイズを含めた新しい幅と高さを決定します $width = $o_width + DS_OFFSET ; $height = $o_height + DS_OFFSET ; $image = imagecreatetruecolor ( $width , $height ); /* determine the offset between colors */ $step_offset = array( "r" => ( $background [ "r" ] / DS_STEPS ), "g" => ( $background [ "g" ] / DS_STEPS ), "b" => ( $background [ "b" ] / DS_STEPS )); /* calculate and allocate the needed colors */ $current_color = $background ; for ( $i = 0 ; $i <= DS_STEPS ; $i ++) { $colors [ $i ] = imagecolorallocate ( $image , round ( $current_color [ "r" ]), round ( $current_color [ "g" ]), round ( $current_color [ "b" ])); $current_color [ "r" ] -= $step_offset [ "r" ]; $current_color [ "g" ] -= $step_offset [ "g" ]; $current_color [ "b" ] -= $step_offset [ "b" ]; } // 一番外側の四角 imagefilledrectangle ( $image , 0 , 0 , $width , $height , $colors [ 0 ]); // だんだん小さく、色を濃く for ( $i = 0 ; $i < count ( $colors ); $i ++) { imagefilledrectangle ( $image , DS_OFFSET , DS_OFFSET , $width , $height , $colors [ $i ]); $width -= DS_SPREAD ; $height -= DS_SPREAD ; }
ボックスをすこしづづ小さく薄く描画して、最終的には、imageconvolution でガウス分布のぼかしを実行しています( ガウス分布のぼかしは、マニュアルのサンプルにあります )
<?php $image = imagecreatetruecolor(180,40); imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00); $gaussian = array( array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0) ); imageconvolution($image, $gaussian, 16, 0);
タグ:gd
|
【PHPの最新記事】
- PHP : 画像を返す処理( readfile ) と画像を縮小する処理( GD )
- PHP における標準的なテスト用アップロードのテンプレート
- PHP : MySQL から JSON 文字列を返す自作(テスト用) API テンプレート
- ImageMagick を Windows(32ビット)の PHP で利用する
- PHPで、ベタベタな日付チェック。汎用的とも言うw
- PHP でカタカナのフリガナ入力のチェック
- TCPDF で罫線を引く
- フリーフォントを使って PHP 画像(GD)として埋め込むアクセスカウンターの DB 処理部分
- フリーフォントを使って PHP 画像(GD)として埋め込むアクセスカウンターの画像出力部分の作成
- PHP : ログインとブラウザの当日日付データ
- hash_hmac は秘密鍵があるので、辞書の総当りとかでパスワードは解りませんから。パスワード抜かれるのは、フィッシングがスパイウェアか、本人が口に出した場合ですね。
- すごく当たり前の事なんですが、UTF-8N で保存されたテキストファイルをメモ帳で変更して保存したら先頭に EF BB BF という爆弾が仕掛けられるのでダメですよ
- PHP で cURL はオプションが全て。いろいろあるので、ちょっとまとめ
- 5秒毎にリロードする PHP ページ
- 実用的かどうかは置いておいて、修正画面の日付入力に jQuery のカレンダーを使用する
- PHPで使用する為にフォント(.TTC)の分解
- PHP : GD で Windows のビットマップを扱う
- 【PHP】 <?=$value?> ではない変数埋め込み手法
- PHPでサービス停止( extension=php_com_dotnet.dll )
- PHP : コマンドライン php(cli) で10進数と16進数の変換