PHP 8.3.4 Released!

imagegetclip

(PHP 7 >= 7.2.0, PHP 8)

imagegetclip長方形を切り取り、画像として取得する

説明

imagegetclip(GdImage $image): array

imagegetclip() 関数は、現在切り取っている長方形を取得します。 つまり、ピクセルが存在しない状態でなければ描画されます。

パラメータ

image

imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。

戻り値

この関数は、切り取っている長方形の座標を配列で返し、 次のエントリを持ちます:

  • 左上のx座標
  • 左上のx座標
  • 右下のx座標
  • 右下のy座標

変更履歴

バージョン 説明
8.0.0 image は、 GdImage クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、有効な gd resource が期待されていました。

例1 imagegetclip() の例

切り取る範囲を設定し、長方形のクリップを取得します。

<?php
$im
= imagecreate(100, 100);
imagesetclip($im, 10,10, 89,89);
print_r(imagegetclip($im));

上の例の出力は以下となります。

Array
(
    [0] => 10
    [1] => 10
    [2] => 89
    [3] => 89
)

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top