エフェクト










画像
#!/usr/local/bin/php
<?php
include_once './rkt_imagemagick.php';

_main();    // 実行関数

// ------------------------------------------------
// 実行関数
// 引数         なし
// 戻り値       なし
// ------------------------------------------------
function _main()
{
    if (empty(
$_POST['manip'])){
        return ;
    }


    
$filename '';
    if (empty(
$_FILES['image']['tmp_name'])) {
        return ;
    }
    if (!
preg_match("/image/i"$_FILES['image']['type'])){
        return ;
    }
    if (!
file_exists ($_FILES['image']['tmp_name'])){
        return ;
    }

    
$filename $_FILES['image']['tmp_name'];
    
$objimg = new RKT_imagemagick($filename);
    
    
$type = empty($_POST['type'])?1:$_POST['type'];
    
    switch (
$type){
    case 
1:     // 回転
        
$objimg->rotate(60);
        break;
    case 
2:     // 渦巻き
        
$objimg->swirl(180);
        break;
    case 
3:     // 波
        
$objimg->wave(10100);
        break;
    case 
4:     // 中央寄せ
        
$objimg->implode(3);
        break;
    case 
5:     // 木炭
        
$objimg->charcoal(3);
        break;
    case 
6:     // フレーム
        
$objimg->frame('lightblue');
        break;
    case 
7:     // ペイント
        
$objimg->paint(3);
        break;
    default:     
// 盛り上げ
        
$objimg->raise(10);
        break;
    }    

    
$objimg->convert('jpg');
    
$objimg->save('effect.jpg');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Cache-Control" content="no-cache">
        <meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT">
        <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
        <meta http-equiv="Content-Style-Type" content="text/css">
        <title>rktImageMagickでエフェクト</title>
    </head>
    <body>
        <form name="imagick" method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <table cellpadding="4" cellspacing="1">
                <tr>
                    <td colspan="4">エフェクト</td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="type" value="1" id="type1" />
                        <label id="off" for="type1">回転</label><br />
                    </td>
                    <td><img src="./img/rotate.jpg" /></td>
                    <td>
                        <input type="radio" name="type" value="2" id="type2" />
                        <label id="off" for="type2">渦巻き</label><br />
                    </td>
                    <td><img src="./img/swirl.jpg" /></td>
                    <td>
                        <input type="radio" name="type" value="3" id="type3" />
                        <label id="off" for="type3">波</label><br />
                    </td>
                    <td><img src="./img/wave.jpg" /></td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="type" value="4" id="type4" />
                        <label id="off" for="type4">中央寄せ</label><br />
                    </td>
                    <td><img src="./img/implode.jpg" /></td>
                    <td>
                        <input type="radio" name="type" value="5" id="type5" />
                        <label id="off" for="type5">木炭</label><br />
                    </td>
                    <td><img src="./img/charcoal.jpg" /></td>
                    <td>
                        <input type="radio" name="type" value="6" id="type6" />
                        <label id="off" for="type6">フレーム</label><br />
                    </td>
                    <td><img src="./img/frame.jpg" /></td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="type" value="7" id="type7" />
                        <label id="off" for="type7">ペイント</label><br />
                    </td>
                    <td><img src="./img/paint.jpg" /></td>
                    <td>
                        <input type="radio" name="type" value="8" id="type8" />
                        <label id="off" for="type8">盛り上げ</label><br />
                    </td>
                    <td><img src="./img/raise.jpg" /></td>
                    <td><br></td>
                    <td><br></td>
                </tr>
                <tr>
                    <td colspan="2">画像</td>
                    <td colspan="2"><input type="file" name="image" style="width:190px;" /></td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align:center;"><input type="submit" name="manip" value="送信" style="width:190px;" /></td>
                </tr>
            </table>
        </form>
        <img src="./effect.jpg" />

<?php   
    highlight_file
('effect.php');
?>
    </body>
</html>