Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 990ff22

Browse files
Added Python for Image Watermark and Plagrism Detector
1 parent 9845197 commit 990ff22

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

‎Plagiarism_detector/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Plagiarism Detector
2+
This script helps to detect the amount (percentage) of similarity between 2 files .
3+
4+
## Input
5+
It takes paths of 2 files you want to compare as input
6+
7+
## Output
8+
It returns the percentage of similarity between the 2 files

‎Plagiarism_detector/plagiarism.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from difflib import SequenceMatcher
2+
3+
def similarity_per(f1,f2):
4+
with open(f1,errors="ignore") as file1,open(f2,errors="ignore") as file2:
5+
file1_data=file1.read()
6+
file2_data=file2.read()
7+
similarity=SequenceMatcher(None,file1_data,file2_data).ratio()
8+
print(f"these 2 files are {similarity*100} % similar")
9+
10+
if __name__ == '__main__':
11+
f1=input("file 1 path :")
12+
f2=input("file 2 path :")
13+
similarity_per(f1,f2)

‎imageWatermarker/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Python script to watermark your images
2+
3+
in the `main.py` file edit the following items:
4+
5+
```bash
6+
"<input folder>",
7+
"<output folder>",
8+
"<watermark image>"
9+
```
10+
11+
using the input folder path to loop over all images and output them to outputfolder.
12+
13+
Best practise is to use a image with transparent background.

‎imageWatermarker/main.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import sys
3+
from os.path import join
4+
from PIL import Image, ImageEnhance
5+
6+
def FolderSelectAndRun():
7+
batch(
8+
"<input folder>",
9+
"<output folder>",
10+
"<watermark image>"
11+
)
12+
13+
14+
basewidth = 2048
15+
16+
def batch(infolder, outfolder, watermark):
17+
mark = Image.open(watermark)
18+
count = 0
19+
for root, dirs, files in os.walk(infolder):
20+
for name in files:
21+
try:
22+
count += 1
23+
im = Image.open(join(root, name))
24+
25+
# New image in the making
26+
layer = Image.new('RGBA', im.size, (0, 0, 0, 0))
27+
position = (im.size[0] - (mark.size[0] + 50),
28+
im.size[1] - (mark.size[1] + 50))
29+
layer.paste(mark, position)
30+
new_image = Image.composite(layer, im, layer)
31+
32+
# Resize in perspective
33+
wpercent = (basewidth / float(im.size[0]))
34+
hsize = int((float(new_image.size[1]) * float(wpercent)))
35+
smaller_new_image = new_image.resize(
36+
(basewidth, hsize), Image.ANTIALIAS)
37+
38+
# Save new smaller image
39+
smaller_new_image.save(
40+
join(outfolder, ('with-watermark_' + name)), 'jpeg')
41+
42+
except Exception as error:
43+
# Debug line while making changes
44+
print('Caught this error: ' + repr(error))
45+
46+
47+
if __name__ == '__main__':
48+
FolderSelectAndRun()

‎imageWatermarker/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pillow==7.2.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /