Migrate to V2: Provide imageMetadataGetter
mainSince version 2.0.0, zca-js no longer includes the sharp dependency for image metadata extraction. If you need to send images or GIFs using a file path, you must provide your own imageMetadataGetter function when initializing the Zalo class.
An implementation using sharp looks like this:
import { Zalo } from "zca-js";
import sharp from "sharp";
import fs from "node:fs";
async function imageMetadataGetter(filePath) {
const data = await fs.promises.readFile(filePath);
const metadata = await sharp(data).metadata();
return {
height: metadata.height,
width: metadata.width,
size: metadata.size || data.length,
};
}
const zalo = new Zalo({
imageMetadataGetter,
});