You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Image\Traits;
use Jcupitt\Vips\Interpretation;
trait ModulateTrait { public function brightness($image, float $brightness = 1.0, float $saturation = 1.0, float $hue = 0.0) { $oldInterpretation = $image->interpretation; $hue %= 360; if ($hue < 0) { $hue = 360 + $hue; } if ($image->hasAlpha()) { $imageWithoutAlpha = $image->extract_band(0, ['n' => $image->bands - 1]); $alpha = $image->extract_band($image->bands - 1, ['n' => 1]); return $imageWithoutAlpha ->colourspace(Interpretation::LCH) ->linear([$brightness, $saturation, 1.0], [0.0, 0.0, $hue]) ->colourspace($oldInterpretation) ->bandjoin($alpha); } return $image ->colourspace(Interpretation::LCH) ->linear([$brightness, $saturation, 1.0], [0.0, 0.0, $hue]) ->colourspace($oldInterpretation); }
}
|