forked from Camillerkt/Multiple-Images-Watermark-Remover
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 29598e9
Showing
7 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
price.txt | ||
node_modules/ | ||
test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |