Im getting this error: leftHalf.quality is not a function
the original image is a jpeg, how to save it with the quality reduced?
const buffer = Buffer.from(decodedData, 'base64')
// Read the image using Jimp (synchronously)
const image = await Jimp.read(buffer)
// Get image dimensions
const width = image.width
const height = image.height
// Calculate the split point (vertical split)
const splitPoint = Math.floor(width / 2)
// Create two new images
const leftHalf = image.clone().crop({ x: 0, y: 0, w: splitPoint, h: height })
const rightHalf = image.clone().crop({ x: splitPoint, y: 0, w: width - splitPoint, h: height })
await leftHalf.write('leftHalf.jpg')
await rightHalf.write('rightHalf.jpg')
await new Promise((resolve, reject) =>
{
leftHalf.quality(70).write('leftHalf2.jpg', (err) =>
{
if (err) reject(err)
else resolve()
})
});
await leftHalf.write(‘leftHalf.jpg’)
await rightHalf.write(‘rightHalf.jpg’)
Both saves the images correctly, but how to also save it with the quality reduced to also reduce their sizes?
I have "jimp": "^1.6.0"