插件14:图像修改

本文介绍了一个用于图像处理和编辑的插件,包括多种图像变换效果,如锐化、模糊、增亮、变暗等,并提供了详细的插件使用说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?php // Plug-in 14: Image Alter

// This is an executable example with additional code supplied
// To obtain just the plug-ins please click on the Download link
// You'll need a jpeg image file called photo.jpg in this folder

$image = imagecreatefromjpeg("photo.jpg");
$copy = PIPHP_ImageAlter($image, 12);
imagejpeg($copy, "photo2.jpg");

echo "<img src='photo.jpg' align=left><img src='photo2.jpg'>";

function PIPHP_ImageAlter($image, $effect)
{
   // Plug-in 14: Image Alter
   //
   // This plug-in takes a GD image and modifies it
   // according to the selected effect. The arguments required
   // are:
   //
   //    $image:  The image source
   //    $effect: The effect to use between 1 and 14:
   //        1 = Sharpen
   //        2 = Blur
   //        3 = Brighten
   //        4 = Darken
   //        5 = Increase Contrast
   //        6 = Decrease Contrast
   //        7 = Grayscale
   //        8 = Invert
   //        9 = Increase Red
   //       10 = Increase Green
   //       11 = Increase Blue
   //       12 = Edge Detect
   //       13 = Emboss
   //       14 = Sketchify

   switch($effect)
   {
      case 1:  imageconvolution($image, array(array(-1, -1, -1),
                  array(-1, 16, -1), array(-1, -1, -1)), 8, 0);
               break;
      case 2:  imagefilter($image,
                  IMG_FILTER_GAUSSIAN_BLUR); break;
      case 3:  imagefilter($image,
                  IMG_FILTER_BRIGHTNESS, 20); break;
      case 4:  imagefilter($image,
                  IMG_FILTER_BRIGHTNESS, -20); break;
      case 5:  imagefilter($image,
                  IMG_FILTER_CONTRAST, -20); break;
      case 6:  imagefilter($image,
                  IMG_FILTER_CONTRAST, 20); break;
      case 7:  imagefilter($image,
                  IMG_FILTER_GRAYSCALE); break;
      case 8:  imagefilter($image,
                  IMG_FILTER_NEGATE); break;
      case 9:  imagefilter($image,
                  IMG_FILTER_COLORIZE, 128, 0, 0, 50); break;
      case 10: imagefilter($image,
                  IMG_FILTER_COLORIZE, 0, 128, 0, 50); break;
      case 11: imagefilter($image,
                  IMG_FILTER_COLORIZE, 0, 0, 128, 50); break;
      case 12: imagefilter($image,
                  IMG_FILTER_EDGEDETECT); break;
      case 13: imagefilter($image,
                  IMG_FILTER_EMBOSS); break;
      case 14: imagefilter($image,
                  IMG_FILTER_MEAN_REMOVAL); break;
   }
   
   return $image;
}

?>

插件说明:

插件14接受一个需要变换的图像和处理要求,具体是:

$image 需要变换的GD图像。

$effect 变换效果,去1~14之间的某个值,如表所示:

插件14中用到的比那里、数组和函数
$effect效果(英文)效果(中文)
1Sharpen锐化
2Blur模糊
3Brighten增亮
4Darken变暗
5Increase contrast增加对比度
6Decrease contrast减小对比度
7Grayscale灰度值
8Invert反转
9Increase red增加红色分量
10Increase green增加绿色分量
11Increase blue增加蓝色分量
12Edge detect边缘检测
13Emboss浮雕化
14Sketchify素描

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值