Closed axkirillov closed 1 year ago
Hi @axkirillov, sorry for the delay, I was trapped in crunch.
You can set the interpretation with copy
, eg.:
$image = $image->copy(["interpretation" => "srgb"]);
That'll copy the image unaltered (it just copies a pointer, no pixels are copied), and tag it as srgb
.
You could make your code a little faster with:
public function getGammaLUT(array $value): Vips\Image
{
return Vips\Image::identity()
->divide(255)
->pow($value)
->multiply(255)
->cast(Vips\BandFormat::UCHAR)
->copy(["interpretation" => "srgb"]);
}
Then use it with maybe:
$power_factors = intGammaToFloatGamma([$this->gammar, $this->gammag, $this->gammab]);
return $image->maplut(getGammaLUT($power_factors));
ie. do the cast on the LUT, not the result, and use an array of constants for pow()
.
Thank you!
When applying the following function
interpretation seems to change from
srgb
tohistogram
, which prevents further composite with error"libvips error: vips_colourspace: no known route from 'multiband' to 'srgb'\n"
what should I do to convert this image back to srgb space?