File indexing completed on 2025-01-26 05:29:14

0001 <?php
0002 
0003 namespace Intervention\Image\Gd\Commands;
0004 
0005 class SharpenCommand extends \Intervention\Image\Commands\AbstractCommand
0006 {
0007     /**
0008      * Sharpen image
0009      *
0010      * @param  \Intervention\Image\Image $image
0011      * @return boolean
0012      */
0013     public function execute($image)
0014     {
0015         $amount = $this->argument(0)->between(0, 100)->value(10);
0016 
0017         // build matrix
0018         $min = $amount >= 10 ? $amount * -0.01 : 0;
0019         $max = $amount * -0.025;
0020         $abs = ((4 * $min + 4 * $max) * -1) + 1;
0021         $div = 1;
0022 
0023         $matrix = [
0024             [$min, $max, $min],
0025             [$max, $abs, $max],
0026             [$min, $max, $min]
0027         ];
0028 
0029         // apply the matrix
0030         return imageconvolution($image->getCore(), $matrix, $div, 0);
0031     }
0032 }