Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * TO FIGURE - PICJOURNEY
- * Author : Gienetic
- * Base : https://play.google.com/store/apps/details?id=com.picjourney.ai.avatar.generator.photo.maker
- * Note : Hanya tofigure, bukan edit image dengan prompt, memang dari apk nya gitu,
- */
- const axios = require("axios")
- const fs = require("fs")
- const FormData = require("form-data")
- const AUTH_TOKEN = "68Gi7PI7gvkx8vovvzSfo1GW8QkqZHQWlfrIme5qA6lHCyVrlfJvm7ojZfrGKSHwDmU4HlklwYqaH8F/QaerlDgIJF3sC+qv4pUWcPIgql3yZgStWVeTNhl8kQq8TXDB3d18uyah1Y8E0JOpznCe3fxqv4y23AmUJyZq9uML/WjDyI5cYUFi9HdKsANOQSqim9uaEPqfUl/7yEE/HwnhP0Pmv0SxFu8r4tFx71ERCM2LGtpIGh8EGYknQjMEsXBFIgyFGnxKpQ/a7XUt5z26l1RYGRma03godmcPgIW0tquaSKQ5DeRBfvW+xKvM0F7XutE7TsQ7EJ3HvD0GNYQcb06Ft33jQZFAsqM5Gc/hI70yrzF9e6BaMjjetYfWoD1S";
- async function toFigure(filePath) {
- try {
- // SENGAJA PAKE UPLOAD DI SERVER ASLI NYA BIAR AMAN, KALO MAU PAKE INPUT URL LAEN SILAHKAN AJA, BEBAS
- const form = new FormData();
- form.append("image", fs.createReadStream(filePath), {
- filename: filePath.split("/").pop(),
- contentType: "image/*"
- });
- const uploadRes = await axios.post("http://43.230.202.197:3033/upload", form, {
- headers: {
- ...form.getHeaders(),
- Authorization: `Bearer ${AUTH_TOKEN}`,
- appName: "picjourney",
- appVersionCode: "18"
- }
- })
- const { url } = uploadRes.data;
- console.log("Upload:", url)
- // MEMBUAT FIGURE MYA
- const startfigure = await axios.post(
- "https://api.magicaigallery.com/v2/aiApi/faceSwap",
- {
- packId: "68c2cef4beee35e738a801db",
- image_url: url
- },
- {
- headers: {
- Authorization: `Bearer ${AUTH_TOKEN}`,
- appName: "picjourney",
- appVersionCode: "18",
- "Content-Type": "application/json; charset=UTF-8"
- }
- }
- );
- const resultUrl = startfigure.data.data.fileUrl
- console.log("Hasil :", resultUrl)
- return resultUrl
- } catch (err) {
- console.error("ā Ada yang salah:", err.response?.data || err.message)
- throw err
- }
- }
- module.exports = toFigure
- /* EXAMPLE:
- const result = await toFigure("./input.jpg")
- console.log("\nš URL hasil :", result)
Add Comment
Please, Sign In to add comment