LoginSignup
1
0

More than 5 years have passed since last update.

imagick php 画像を丸く 切り抜く

Last updated at Posted at 2018-05-13

画像を丸く切り抜きたい。

考え方

・四角い画像を用意しよう
・その上に丸いマスク画像を合成しよう
・マスク画像で切り抜こう


public function createImg()
{
    $icon = WWW_ROOT . "img/usericon.png";   //ユーザーアイコン
    $mask = WWW_ROOT . "img/mask.png";   //マスク 丸い黒い画像を用意


    /* 画像の読み込み */
    $icon = new \Imagick($icon);
    $mask = new \Imagick($mask);

    $icon->compositeImage($mask, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);


    /* 画像を出力 */
    header("Content-Type: image/jpeg");     //表示する画像ヘッダー
    echo $icon;

    die;

}

以上です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0