I am using libvips PHP library, I am applying some effects on my image using the library and it's work very charm, but somehow for one image it's not working properly and giving me below error
Note - I m getting this error only the image which I uploaded, in other images, it works for me
Fatal error: Uncaught Jcupitt\Vips\Exception: recomb: bands in must equal matrix width
I think the issue is with the image band the image which has 3 bands it's working but for band 1 it's giving me errors.
Here is the code which I am using for apply b & w effect on my image
$img = Vips\Image::newFromFile($inputFileName, ['access' => 'sequential']);
//Matrix for black and white image
$technicolor = Vips\Image::newFromArray([
[0.2225, 0.7169, 0.0606],
[0.2225, 0.7169, 0.0606],
[0.2227, 0.7169, 0.0606],
]);
if ($img->hasAlpha()) {
$imageWithoutAlpha = $img->extract_band(0, ['n' => $img->bands - 1]);
$alpha = $img->extract_band($img->bands - 1, ['n' => 1]);
$img = $imageWithoutAlpha->recomb($technicolor)->bandjoin($alpha);
}
$img = $img->recomb($technicolor);
$img->writeToFile($outputFileName);
Here is the image info
error-img.jpg: 2000x1334 uchar, 1 band, b-w, jpegload
width: 2000
height: 1334
bands: 1
format: uchar
coding: none
interpretation: b-w
xoffset: 0
yoffset: 0
xres: 11.811
yres: 11.811
filename: error-img.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:4:4
iptc-data: 12836 bytes of binary data
exif-data: 13500 bytes of binary data
resolution-unit: in
exif-ifd0-Make: Canon (Canon, ASCII, 6 components, 6 bytes)
exif-ifd0-Model: Canon EOS 7D (Canon EOS 7D, ASCII, 13 components, 13 bytes)
exif-ifd0-XResolution: 300/1 (300, Rational, 1 components, 8 bytes)
exif-ifd0-YResolution: 300/1 (300, Rational, 1 components, 8 bytes)
exif-ifd0-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
exif-ifd0-Software: Adobe Photoshop Camera Raw 8.1 (Windows) (Adobe Photoshop Camera Raw 8.1 (Windows), ASCII, 41 components, 41 bytes)
exif-ifd0-DateTime: 2013:09:05 23:59:59 (2013:09:05 23:59:59, ASCII, 20 components, 20 bytes)
exif-ifd0-Artist: Nik. Gribas - gnikos@hotmail.com (Nik. Gribas - gnikos@hotmail.com, ASCII, 33 components, 33 bytes)
exif-ifd0-Copyright: Nik. Gribas (Nik. Gribas (Photographer) - [None] (Editor), ASCII, 12 components, 12 bytes)
exif-ifd1-Compression: 6 (JPEG compression, Short, 1 components, 2 bytes)
exif-ifd1-XResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd1-YResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd1-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
exif-ifd2-ExposureTime: 1/5 (1/5 sec., Rational, 1 components, 8 bytes)
exif-ifd2-FNumber: 4/1 (f/4.0, Rational, 1 components, 8 bytes)
exif-ifd2-ExposureProgram: 1 (Manual, Short, 1 components, 2 bytes)
exif-ifd2-ISOSpeedRatings: 1600 (1600, Short, 1 components, 2 bytes)
exif-ifd2-ExifVersion: Exif Version 2.3 (Exif Version 2.3, Undefined, 4 components, 4 bytes)
exif-ifd2-DateTimeOriginal: 2013:08:30 23:49:47 (2013:08:30 23:49:47, ASCII, 20 components, 20 bytes)
exif-ifd2-DateTimeDigitized: 2013:08:30 23:49:47 (2013:08:30 23:49:47, ASCII, 20 components, 20 bytes)
exif-ifd2-ShutterSpeedValue: 2321928/1000000 (2.32 EV (1/4 sec.), SRational, 1 components, 8 bytes)
exif-ifd2-ApertureValue: 4/1 (4.00 EV (f/4.0), Rational, 1 components, 8 bytes)
exif-ifd2-ExposureBiasValue: 0/1 (0.00 EV, SRational, 1 components, 8 bytes)
exif-ifd2-MaxApertureValue: 3/1 (3.00 EV (f/2.8), Rational, 1 components, 8 bytes)
exif-ifd2-MeteringMode: 5 (Pattern, Short, 1 components, 2 bytes)
exif-ifd2-Flash: 16 (Flash did not fire, compulsory flash mode, Short, 1 components, 2 bytes)
exif-ifd2-FocalLength: 17/1 (17.0 mm, Rational, 1 components, 8 bytes)
exif-ifd2-SubSecTimeOriginal: 64 (64, ASCII, 3 components, 3 bytes)
exif-ifd2-SubSecTimeDigitized: 64 (64, ASCII, 3 components, 3 bytes)
exif-ifd2-FocalPlaneXResolution: 5184000/907 (5715.546, Rational, 1 components, 8 bytes)
exif-ifd2-FocalPlaneYResolution: 3456000/595 (5808.403, Rational, 1 components, 8 bytes)
exif-ifd2-FocalPlaneResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
exif-ifd2-CustomRendered: 0 (Normal process, Short, 1 components, 2 bytes)
exif-ifd2-ExposureMode: 1 (Manual exposure, Short, 1 components, 2 bytes)
exif-ifd2-WhiteBalance: 0 (Auto white balance, Short, 1 components, 2 bytes)
exif-ifd2-SceneCaptureType: 0 (Standard, Short, 1 components, 2 bytes)
exif-ifd2-FlashPixVersion: FlashPix Version 1.0 (FlashPix Version 1.0, Undefined, 4 components, 4 bytes)
exif-ifd2-ColorSpace: 65535 (Internal error (unknown value 65535), Short, 1 components, 2 bytes)
jpeg-thumbnail-data: 12598 bytes of binary data
xmp-data: 10134 bytes of binary data
icc-profile-data: 408 bytes of binary data
The Image in which I am getting error