I am using the PHP libvips library, I have a function that applies background colour on images using vips flatten
method. The issue is when I am trying to apply background colour to .jpg image it gives me the below error
Fatal error: Uncaught Jcupitt\Vips\Exception: linear: vector must have 1 or 2 elements
My Code for applying background colour on image
$img = Vips\Image::newFromFile($inputFileName, ['access' => 'sequential']);
$img = $img->flatten(['background' => [255, 0, 0]]);
$img->writeToFile($outputFileName);
The image which I am trying to apply background color
Note: When I am using Imagick library it also doesn't apply the bg colour on the image but it doesn't give me an error. How can I prevent this in LibVips??
It works fine when image type is png and jpeg