Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Camillerkt committed Jun 22, 2022
0 parents commit 29598e9
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
price.txt
node_modules/
test.js
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Multiple Images Watermak Remover

### Mode of operation

The program uses the webscraping technique and uses the watermarkremover.io website to remove watermarks from images of your choice.
The edited files will be saved in the download directory of your machine.

The code is written in **NodeJS** (JavaScript) and uses the NPM package "_puppeteer_".

### Why use the program ?

You don't need this program if you are a simple person who wants to remove a watermark from an image of your choice.
But if you are a developer creating an ambitious project in which you want to use the watermark removal technique on multiple images and add other features, you can use the piece of code provided in the `index.js` file to adapt it to your needs.

### How to install and use it ?

**First of all, I'd like to point out that this program uses the 2captcha API to bypass any Captchas that may occur during scraping.
Create a developer account on 2captcha.com and get your token. You will have to pay a few dollars to make it work, but don't worry, it's not expensive at all (about 3 USD for 1000 captchas) !**

- Have `NodeJS` installed on your machine
- Download the project
- Run the `npm install` command in your terminal
- Put the URLs of your images in the file `imagesUrl.txt` (one URL per line)
- On line 9 of `index.js` : `provider: { id: "2captcha", token: "XXXX" }`, paste **your 2captcha token** in place of the `XXXX`.
- Run the program: `node index.js` in your terminal

### Author

Website : https://camillerakoto.fr

![enjoy !](https://memegenerator.net/img/instances/81307932.jpg)
Empty file added imagesUrl.txt
Empty file.
73 changes: 73 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const fs = require("fs");
const puppeteer = require("puppeteer-extra");
const RecaptchaPlugin = require("puppeteer-extra-plugin-recaptcha");
const download = require("image-downloader");

puppeteer.use(
RecaptchaPlugin({
provider: { id: "2captcha", token: "XXXX" },
visualFeedback: true, // colorize reCAPTCHAs (violet = detected, green = solved)
})
);

(async () => {
// for each line in imagesUrl.txt, put the image url in array
const imagesUrl = await fs
.readFileSync("imagesUrl.txt", "utf8")
.split("\n")
.filter((url) => url !== "");

const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });

for (let i = 0; i < imagesUrl.length; i++) {
const imagePath = await downloadOriginalImage(imagesUrl[i]);

await page.goto("https://www.watermarkremover.io/upload", {
waitUntil: "load",
});

await page.waitForSelector("input[type=file]");
const fileInput = await page.$("input[type=file]");
await fileInput.uploadFile(imagePath);

/* resolve captcha */
await page.evaluate(() => {
window.scroll(0, 0);
});
await sleep(1000);
await page.solveRecaptchas();
/* end resolve captcha */

await page.waitForSelector(".hyUBYz");
await page.click(".hyUBYz");

await sleep(500);

// To clear all previous uploaded images from the page
await page.evaluate(() => {
localStorage.clear();
});
}
})();

const downloadOriginalImage = async (imageUrl) => {
const options = {
url: imageUrl,
dest: __dirname + "/original_images",
};

return download
.image(options)
.then(({ filename }) => {
return filename;
})
.catch((err) => console.error(err));
};

function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
Binary file added original_images/.DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "photorunningwatermarkremover",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"image-downloader": "^4.3.0",
"nodemon": "^2.0.16",
"puppeteer": "^14.4.1",
"puppeteer-extra": "^3.3.0",
"puppeteer-extra-plugin-recaptcha": "^3.6.0"
}
}

0 comments on commit 29598e9

Please sign in to comment.