PHP 中的 imageflip() 函数

phpserver side programmingprogramming更新于 2025/7/6 9:37:17

imageflip() 函数用于使用指定模式翻转图像。

语法

bool imageflip(img, mode )

参数

  • img:使用 imagecreatetruecolor() 创建的图像资源

  • mode:翻转模式。以下是可能的值:

  • IMG_FLIP_HORIZONTAL - 水平翻转图像。

  • IMG_FLIP_VERTICAL -垂直翻转图像。

  • IMG_FLIP_BOTH – 同时水平和垂直翻转图像。

返回

imageflip() 函数成功时返回 TRUE,失败时返回 FALSE。

示例

以下是水平翻转图像的示例:

<?php
   $img_file = 'http://www.tutorialspoint.com/images/tp-logo-diamond.png';
   header('Content-type: image/png');
   $img = imagecreatefrompng($img_file);
   imageflip($img, IMG_FLIP_HORIZONTAL);
   imagejpeg($img);
   imagedestroy($img);
?>

输出

输出结果如下:


相关文章