File size: 529 Bytes
c23f777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const axios = require("axios");

module.exports = async function processImage(link) {
  if (!link) throw new Error("No link provided");
  try {
    let image = await axios.get(link, { responseType: "arraybuffer" });

    return {
      mimetype: "image/jpeg",
      data: Buffer.from(image.data).toString("base64"),
      filename: "whatsbotimage",
      error: null,
    };
  } catch (error) {
    return {
      mimetype: "image/jpeg",
      data: "",
      filename: "whatsbotimage",
      error: error.message,
    };
  }
};