Ayogiakbar

Image HD Enhancer

Aug 31st, 2025 (edited)
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Image HD Enhancer
  3.  * Author  : gienetic
  4.  * Base  : https://play.google.com/store/apps/details?id=com.reaimagine.enhanceit
  5.  */
  6.  
  7. const axios = require("axios");
  8. const fs = require("fs");
  9. const FormData = require("form-data");
  10.  
  11. const Keyy = "-mY6Nh3EWwV1JihHxpZEGV1hTxe2M_zDyT0i8WNeDV4buW9l02UteD6ZZrlAIO0qf6NhYA";
  12.  
  13. async function sleep(ms) {
  14.   return new Promise((resolve) => setTimeout(resolve, ms));
  15. }
  16.  
  17. async function processImage(inputPath) {
  18.   try {
  19.     const form = new FormData();
  20.     form.append("file", fs.createReadStream(inputPath));
  21.  
  22.     const uploadRes = await axios.post(
  23.       "https://reaimagine.zipoapps.com/enhance/autoenhance/",
  24.       form,
  25.       {
  26.         headers: {
  27.           ...form.getHeaders(),
  28.           Authorization: Keyy,
  29.           "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 10; Redmi Note 5 Pro Build/QQ3A.200805.001)",
  30.         },
  31.       }
  32.     );
  33.  
  34.     const name = uploadRes.headers["name"] || uploadRes.data?.name;
  35.     if (!name) throw new Error("Gagal ambil 'name' dari upload response");
  36.  
  37.     let attempts = 0;
  38.     const maxAttempts = 20;
  39.  
  40.     while (attempts < maxAttempts) {
  41.       attempts++;
  42.       try {
  43.         const res = await axios.post(
  44.           "https://reaimagine.zipoapps.com/enhance/request_res/",
  45.           null,
  46.           {
  47.             headers: {
  48.               name,
  49.               app: "enhanceit",
  50.               ad: "0",
  51.               Authorization: Keyy,
  52.               "Content-Type": "application/x-www-form-urlencoded",
  53.               "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 10; Redmi Note 5 Pro Build/QQ3A.200805.001)",
  54.             },
  55.             responseType: "arraybuffer",
  56.             validateStatus: () => true,
  57.           }
  58.         );
  59.  
  60.         if (res.status === 200 && res.data && res.data.length > 0) {
  61.           return Buffer.from(res.data);
  62.         }
  63.       } catch {}
  64.  
  65.       await sleep(5000);
  66.     }
  67.  
  68.     throw new Error("Gagal dapat hasil setelah banyak percobaan.");
  69.   } catch (err) {
  70.     throw err;
  71.   }
  72. }
  73.  
  74. module.exports = { processImage };
  75.  
Add Comment
Please, Sign In to add comment