const axios = require('axios'); const cheerio = require('cheerio'); const FormData = require('form-data'); async function imagetools(buffer, type) { try { const _type = ['removebg', 'enhance', 'upscale', 'restore', 'colorize']; if (!buffer || !Buffer.isBuffer(buffer)) throw new Error('Image buffer is required'); if (!_type.includes(type)) throw new Error(`Available types: ${_type.join(', ')}`); const form = new FormData(); form.append('file', buffer, `${Date.now()}_rynn.jpg`); form.append('type', type); const { data } = await axios.post('https://imagetools.rapikzyeah.biz.id/upload', form, { headers: form.getHeaders() }); const $ = cheerio.load(data); const res = $('img#memeImage').attr('src'); if (!res) throw new Error('No result found'); return res; } catch (error) { throw new Error(error.message); } } // Usage: const fs = require('fs'); const resp = await imagetools(fs.readFileSync('./image.jpg'), 'upscale'); console.log(resp);