const axios = require('axios'); const fetch = require('node-fetch'); const fs = require('fs'); const FormData = require('form-data'); const uploadImage = require('../lib/uploadImage.js');

const handler = async (m, { conn, usedPrefix, command, text }) => { let q = m.quoted ? m.quoted : m; let mime = (q.msg || q).mimetype || ''; if (!mime) throw 'Send/Reply Images with the caption .jadianime'; conn.chatRead(m.chat) conn.sendMessage(m.chat, { react: { text: '🕒', key: m.key, } }) let media = await q.download(); let url = await uploadImage(media); let styles = ['anime', 'angel', 'princess', 'manhwa_female', 'manhwa_male'];

let sendPromises = styles.map(async (style) => { const queryParams = { style: style, json: false, };

const response = await fetch(url);
const buffer = await response.buffer();

const form = new FormData();
form.append('file', buffer, {
  filename: 'image.jpg',
  contentType: 'image/jpeg',
  knownLength: buffer.length,
});

const { data } = await axios
  .request({
    baseURL: 'https://api.itsrose.life',
    url: '/image/differentMe',
    method: 'POST',
    params: {
      ...queryParams,
      apikey: global.rose,
    },
    data: form,
    responseType: 'arraybuffer', 
  })
  .catch((e) => e?.response?.data);

if (!data) {
  throw 'Failed to process image.';
}

const resultBuffer = Buffer.from(data, 'binary'); 

let caption = `STYLE: ${style.replace(/_/g, ' ').toUpperCase()}`;

return conn.sendFile(m.chat, resultBuffer, 'ppk.jpg', caption, m);

}); await Promise.all(sendPromises); };

handler.help = ['jadianime']; handler.tags = ['tools']; handler.command = /^(jadianime)$/i; handler.limit = true; handler.private = false;

module.exports = handler;

Convert Images to Different Anime Styles with *jadianime* Command

原文地址: https://www.cveoy.top/t/topic/o7U0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录