サイトを更新しています。 数日間、レイアウトや翻訳に不具合が出ることがあります。ドキュメントは引き続きご利用いただけます。表示が崩れている場合は、後ほど再読み込みしてください。

ホーム image 3.x 画像の挿入

画像の挿入

3.x 2026年3月7日

#画像の挿入

public Image::place(mixed $element, string $position = 'top-left', int $offset_x = 0, int $offset_y = 0, int $opacity = 100): ImageInterface

指定した位置に画像を挿入します。挿入する画像は サポートされている画像ソース のいずれかで指定できます。必要に応じて、指定位置からの相対オフセットとして座標を渡せます。opacity パラメータで透かしの不透明度を制御することもできます。

使用できる position の値は次のとおりです:

  • top-left (default)
  • top
  • top-right
  • left
  • center
  • right
  • bottom-left
  • bottom
  • bottom-right

#パラメータ

Name Type Description
element mixed 挿入する画像のソース
position string 挿入する画像の位置
offset_x int x軸方向の相対オフセット(任意)
offset_y int y軸方向の相対オフセット(任意)
opacity int 挿入する画像の不透明度。0(完全に透明)〜100(不透明)の範囲で指定します

#

use Intervention\Image\ImageManager;

// ファイルからテスト画像を作成
$manager = ImageManager::gd();
$image = $manager->read('test.png');

// 別の画像を貼り付ける
$img->place('images/foo.png');

// サイズ変更した透かしの新しいインスタンスを作成し、右下に挿入します
// 10px のオフセットと 25% の不透明度で
$img->place(
    'images/watermark.png',
    'bottom-right', 
    10, 
    10,
    25
);