昨日は遅すぎてプログラムまでできませんでした。。
たまたまあった愛車のリコール整備のためディーラーにてお勉強。
これぞプログラミングのお手軽さですね。
結果的にはすごく簡単(いろいろなサンプルを利用させていただきました)。
画像作成部分のプログラムは次のような感じ。
define('WORK_TMP', 'Webサーバを動かすアカウントが書き込みできるディレクトリ'); // Work function makeRoundImage($imageUrl) { $round_pix_x = round_pix_y = 20; $file = WORK_TMP . "/" . date("Ymdh") . "_" . sha1($imageUrl) . ".png"; $image =& new Imagick(); $image->readImage($imageUrl); $image->roundCorners($round_pix_x, $round_pix_y); $image->setImageFormat('png'); $image->writeImage($file); output_image($file, "png"); } function output_image($file, $ext) { header('Content-type: image/' . $ext); header('Content-Disposition: inline; filename=' . basename($file)); readfile($file); exit(); }
目出たく、背景透過の角丸pngの画像が作成されました。
なんという便利さ。
■元画像
■変換後
当然のごとく、$round_pix_x, round_pix_yに別のサイズを指定すると合わせて作りかえてくれます。
一旦個人用に作っただけなんですが、キャッシュファイル削除するとことか組み込んで、動作するツールとして公開します。