import qrcode
img = qrcode.make('Binoy Thomas')
print(type(img)) # <class 'qrcode.image.pil.PilImage'>
print(img.size) # (290, 290)
img.save('QR.png')
img = qrcode.make('Binoy Thomas')
print(type(img)) # <class 'qrcode.image.pil.PilImage'>
print(img.size) # (290, 290)
img.save('QR.png')
https://www.section.io/engineering-education/steganography-in-python/
# pip install opencv-python
from tkinter import *
from PIL import Image, ImageTk
from tkinter import filedialog
import cv2
import numpy as np
import math
global path_image
image_display_size = 300, 300
def OnClick():
global path_image
path_image = filedialog.askopenfilename()
load_image = Image.open(path_image)
load_image.thumbnail(image_display_size, Image.ANTIALIAS)
np_load_image = np.asarray(load_image)
np_load_image = Image.fromarray(np.uint8(np_load_image))
render = ImageTk.PhotoImage(np_load_image)
img = Label(app, image=render)
img.image = render
img.place(x=20, y=50)
def Encrypt():
global path_image
data = txt.get(1.0, "end-1c")
img = cv2.imread(path_image)
data = [format(ord(i), '08b') for i in data] # break image to binary chararacters
_, width, _ = img.shape
PixReq = len(data) * 3 # algorithm to encode the image
RowReq = PixReq/width
RowReq = math.ceil(RowReq)
count = 0
charCount = 0
for i in range(RowReq + 1):
while(count < width and charCount < len(data)):
char = data[charCount]
charCount += 1
for index_k, k in enumerate(char):
if((k == '1' and img[i][count][index_k % 3] % 2 == 0) or (k == '0' and img[i][count][index_k % 3] % 2 == 1)):
img[i][count][index_k % 3] -= 1
if(index_k % 3 == 2):
count += 1
if(index_k == 7):
if(charCount*3 < PixReq and img[i][count][2] % 2 == 1):
img[i][count][2] -= 1
if(charCount*3 >= PixReq and img[i][count][2] % 2 == 0):
img[i][count][2] -= 1
count += 1
count = 0
cv2.imwrite("EncryptedImage.png", img)
success_label = Label(app, text="Encrypted!", bg='lavender', font=("Helvetica", 20))
success_label.place(x=130, y=360)
app = Tk()
app.configure(background='lavender')
app.title("Encrypt")
app.geometry('400x400')
btnSelect = Button(app, text="Select PNG Image (Max 500 x 300)", command=OnClick)
btnSelect.place(x=100, y=10)
txt = Text(app, wrap=WORD, width=30)
txt.place(x=80, y=220, height=100)
encrypt_button = Button(app, text="Encode", bg='white', fg='black', command=Encrypt)
encrypt_button.place(x=180, y=328)
app.mainloop()
from tkinter import *
import time
import sys
root=Tk()
root.title("Digital Clock")
def get_time():
time_string=time.strftime("%I:%M:%S %p")
clock.config(text=time_string)
clock.after(170, get_time)
clock = Label(root, font=("time", 90, "bold"), bg="green")
clock.pack()
get_time()
root.mainloop()

import moviepy.editor as mpy
clip = mpy.VideoFileClip("Valayosai gala gala.mp4")
myClip = clip.subclip(0, 5) # From 0s to 5s
#myClip.resize(0.5) # width & heigth halved
#myClip.resize(width=800) # Height computed automatically
myClip.write_gif("Valayosai.gif")
import mysql.connector as mc
from art import text2art as t2a
def Display(recs, nor, src):
if src != "delete":
print("\nRoll F_Name L_Name Sex Average")
print("==== ====== ====== === =======")
if nor == 1:
print("%3s %-11s %-11s %1s %10s" % (recs[0], recs[1], recs[2], recs[3], recs[4]))
else:
for rec in recs:
print("%3s %-11s %-11s %1s %10s" % (rec[0], rec[1], rec[2], rec[3], rec[4]))
print("\n", nor, "records displayed")
def display():
conn = mc.connect(host="localhost", user="root", passwd="root", database="test")
cur = conn.cursor()
cur.execute("SELECT * FROM students")
records = cur.fetchall()
count = cur.rowcount
if count == 0:
print("Empty table")
else:
Display(records, cur.rowcount, "display")
conn.close()
input("\nPress any key to continue ...\n")
def add():
conn = mc.connect(host="localhost", user="root", passwd="root", database="test")
cur = conn.cursor()
role = int(input("Enter roll number: "))
fnm = input("Enter first name: ")
lnm = input("Enter last name: ")
s = input("Enter sex: ")
aver = float(input("Enter average: "))
sql = "INSERT INTO students(roll, fname, lname, sex, avg) VALUES(%s, %s, %s, %s, %s)"
values = (role, fnm, lnm, s, aver)
cur.execute(sql, values)
conn.commit()
conn.close()
input("\nPress any key to continue ...\n")
def search():
conn = mc.connect(host="localhost", user="root", passwd="root", database="test")
cur = conn.cursor()
field = input("Enter field to be searched: ")
if field == "roll":
cond = input("Enter roll to search for: ")
query = "SELECT * FROM students WHERE roll = '" + cond + "'"
elif field == "fname":
cond = input("Enter fname to search for: ")
query = "SELECT * FROM students WHERE fname = '" + cond + "'"
elif field == "lname":
cond = input("Enter lname to search for: ")
query = "SELECT * FROM students WHERE lname = '" + cond + "'"
elif field == "sex":
cond = input("Enter sex to search for: ")
query = "SELECT * FROM students WHERE sex = '" + cond + "'"
elif field == "avg":
opt = input("Search for >, <, >=, <=, == or !=: ")
cond = input("Enter avg to search for: ")
query = "SELECT * FROM students WHERE avg " + opt + " " + cond
print()
cur.execute(query)
records = cur.fetchall()
if cur.rowcount == 0:
print("No records returned")
else:
Display(records, cur.rowcount, "search")
conn.close()
input("\nPress any key to continue ...\n")
def modify():
role = int(input("Enter roll no of record to modify: "))
conn = mc.connect(host="localhost", user="root", passwd="root", database="test")
cur = conn.cursor()
query = "SELECT * FROM students WHERE roll = " + str(role)
print(query)
cur.execute(query)
rec = cur.fetchall()
Display(rec, 1, "modify")
ans = input("Are you sure you wish to update this record? (Y/N) ")
if ans.upper() == 'Y':
fnm = input("Enter new first name : ")
lnm = input("Enter new last name : ")
sx = input("Enter sex : ")
aver = input("Enter new average: ")
cur.execute("UPDATE students SET fname = '" + fnm + "' WHERE roll = " + str(role))
cur.execute("UPDATE students SET lname = '" + lnm + "' WHERE roll = " + str(role))
cur.execute("UPDATE students SET sex = '" + sx + "' WHERE roll = " + str(role))
cur.execute("UPDATE students SET avg = '" + aver + "' WHERE roll = " + str(role))
conn.commit()
conn.close()
input("\nPress any key to continue ...\n")
def delete():
role = input("\nEnter roll no of record to delete: ")
conn = mc.connect(host="localhost", user="root", passwd="root", database="test")
cur = conn.cursor()
query = "SELECT * FROM students WHERE roll = " + role
cur.execute(query)
rec = cur.fetchone()
if cur.rowcount == 1:
Display(rec, 1, "delete")
ans = input("\nDelete this record? (Y/N)")
if ans.upper() == 'Y':
cur.execute("DELETE FROM students WHERE roll = " + role)
conn.commit()
else:
print("Record not found")
input("\nPress any key to continue ...\n")
choice = 0
while True:
print(t2a(" STUDENT DATABASE"))
print("\t\t\t\t\t\t\t\tPrepared by T. V. Thomas (Regn. No. __)")
print("1. Display all records")
print("2. Add record")
print("3. Search record")
print("4. Modify record")
print("5. Delete record")
print("6. Display sorted records")
print("0. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
display()
elif choice == 2:
add()
elif choice == 3:
search()
elif choice == 4:
modify()
elif choice == 5:
delete()
elif choice == 6:
pass
elif choice == 0:
break
else:
print("Wrong choice")