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.
 
 
 
 

28 lines
987 B

<?php
namespace App\Image;
use Jcupitt\Vips\Interpretation;
class Processor {
public static 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);
}
}