Skip to content

Commit d551692

Browse files
authored
Merge pull request #13 from subhayu99/LastPR
PR-4
2 parents 6ec19a4 + b3127c1 commit d551692

File tree

7 files changed

+169
-0
lines changed

7 files changed

+169
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
'''
2+
Script uses Pillow module to read the image and convert it to png.
3+
sys module for accepting inputs from terminal and os module
4+
for operations on pathnames.
5+
6+
Install Pillow module through "pip install pillow"
7+
'''
8+
9+
import sys,os
10+
from PIL import Image
11+
12+
source_folder = sys.argv[1] # Accepts source folder given in terminal
13+
destination_folder = sys.argv[2] # Accepts destination folder given in terminal
14+
15+
if not os.path.exists(destination_folder): #Check if destination folder exists,if not creates one
16+
os.makedirs(destination_folder)
17+
18+
choice=1
19+
while choice!=5:
20+
print("Press 1 -> To convert to PNG")
21+
print("Press 2 -> To convert to SVG")
22+
print("Press 3 -> To convert to GIF")
23+
print("Press 4 -> To Exit")
24+
choice=int(input("Enter your Choice: "))
25+
print()
26+
if choice==1:
27+
for filename in os.listdir(source_folder): # For each file present in Source folder
28+
file = os.path.splitext(filename)[0] # Splits file name into as tuple as ('filename','.extension')
29+
img = Image.open(f'{source_folder}/{filename}')
30+
img.save(f'{destination_folder}/{file}.png','png') #Converts to png format
31+
print("Image converted to PNG!")
32+
print()
33+
34+
elif choice==2:
35+
for filename in os.listdir(source_folder): # For each file present in Source folder
36+
file = os.path.splitext(filename)[0] # Splits file name into as tuple as ('filename','.extension')
37+
img = Image.open(f'{source_folder}/{filename}')
38+
img.save(f'{destination_folder}/{file}.svg','svg') #Converts to svg format
39+
print("Image converted to SVG!")
40+
print()
41+
42+
elif choice==3:
43+
for filename in os.listdir(source_folder): # For each file present in Source folder
44+
file = os.path.splitext(filename)[0] # Splits file name into as tuple as ('filename','.extension')
45+
img = Image.open(f'{source_folder}/{filename}')
46+
img.save(f'{destination_folder}/{file}.gif','gif') #Converts to gif format
47+
print("Image converted to GIF!")
48+
print()
49+
50+
else:
51+
sys.exit()
52+
53+
54+
'''
55+
Sample input to run in terminal:
56+
->Python3 JpgToPngConvertor.py Source_Images Destination_Images
57+
58+
Output:
59+
Press 1 -> To convert to PNG
60+
Press 2 -> To convert to SVG
61+
Press 3 -> To convert to GIF
62+
Press 4 -> To Exit
63+
Enter your Choice: 1
64+
65+
Images converted to PNG!
66+
'''
67+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# JPG to All Picture Format Convertor
2+
3+
* This script converts the list of JPG images available in source folder to PNG, SVG, and GIF images
4+
which will get stored in destination folder with help of Pillow module.
5+
6+
* Pillow is a free and open-source additional library for the Python programming language
7+
that adds support for opening, manipulating, and saving many different image file formats.
8+
9+
* Pillow module can be installed using following command "pip install pillow"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Importing required libraries
2+
from urllib.request import Request, urlopen
3+
from bs4 import BeautifulSoup
4+
from xlwt import Workbook
5+
from datetime import datetime
6+
7+
#Tacking URL input from user
8+
url=input("Enter site to get links\n")
9+
links=[]
10+
while(len(url)==0):
11+
url=input("Enter site to get links\n")
12+
try:
13+
# Sending request to server using Urllib
14+
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
15+
html_data = urlopen(req).read()
16+
17+
#Beautyfying all data to html form
18+
soup=BeautifulSoup(html_data,'html.parser')
19+
20+
#Retriving all anchor tags in html data
21+
tags=soup('a')
22+
23+
#Adding all href attribute values to list
24+
for tag in tags:
25+
if tag.has_attr('href'):
26+
links.append(tag['href'])
27+
except:
28+
#Check if any errors
29+
print("Please check the URL properly")
30+
if(len(links)==0):
31+
print("No links to fetch")
32+
else:
33+
# Tackning workbook
34+
wb=Workbook()
35+
36+
#Creaing sheet in workbook
37+
sheet1 = wb.add_sheet('Links')
38+
39+
#adding all data in list to excel sheet
40+
for i in range(0,len(links)):
41+
sheet1.write(i,0,links[i])
42+
43+
#Getting date and time to create file
44+
data_time=datetime.now()
45+
current_time = str(data_time.strftime("%H-%M-%S"))
46+
47+
#Adding time to file name and saving file locally
48+
wb.save('links for '+current_time+'.xls')
49+
print("Done writing data to excel sheet")

Automation/LinksExtractor/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Links extractor script
2+
Links extractor is a python script which helps in extracting all the links in a web page.
3+
It goes through all the content in html data and extract data from all anchor tags.
4+
5+
## Libraries used
6+
* urllib is a python library used to send request used to website to retrive html content
7+
8+
* bs4 is used to extract data from html content
9+
10+
* xlwt is a python library used to write data to excel sheet

Automation/QrScanner/QR.png

469 Bytes
Loading

Automation/QrScanner/QrScanner.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import cv2 ##import the module opencv
2+
import numpy as np ##import the module numpy
3+
import pyzbar.pyzbar as pyzbar ##import the module pyzbar
4+
5+
img = cv2.imread("QR.png") ##read your image
6+
decode_QR = pyzbar.decode(img) ##function to decode QR
7+
8+
for i in decode_QR:
9+
print("your scanned QR :",i.data)
10+
11+
cv2.imshow("QR ", img) ##display Cropped image
12+
cv2.waitKey(0)

Automation/QrScanner/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Image Processing
2+
3+
Image Processing is most commonly termed as 'Digital Image Processing' and the domain in which it is frequently used is 'Computer Vision'.
4+
Don't be confused - we are going to talk about both of these terms and how they connect.
5+
Both Image Processing algorithms and Computer Vision (CV) algorithms take an image as input; however, in image processing,
6+
the output is also an image, whereas in computer vision the output can be some features/information about the image.
7+
8+
## OpenCV
9+
10+
![](https://logodix.com/logo/1989939.png)
11+
12+
## Installation
13+
14+
### Windows
15+
$ pip install opencv-python
16+
$ pip install pyzbar
17+
### MacOS
18+
$ brew install opencv3 --with-contrib --with-python3
19+
$ brew install zbar
20+
### Linux
21+
$ sudo apt-get install libopencv-dev python-opencv
22+
$ sudo apt-get install libzbar0

0 commit comments

Comments
 (0)