aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-08-19 12:44:08 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-08-19 12:44:08 +0530
commit8788843458f614a609f936ecdb1fc6c49c2cbf9b (patch)
tree605d8e9cc44011bc28ee2291e741a79ec4e4c15e /src
parent0cc9cc2813f9d630436677229e6f311403180a18 (diff)
added custom date and time option
Diffstat (limited to 'src')
-rw-r--r--src/VHSImage.py60
-rw-r--r--src/VHSVideo.py8
2 files changed, 29 insertions, 39 deletions
diff --git a/src/VHSImage.py b/src/VHSImage.py
index ebf057f..ab64ec0 100644
--- a/src/VHSImage.py
+++ b/src/VHSImage.py
@@ -8,6 +8,7 @@ import imageio
import random
from math import floor
import os
+import logzero
from logzero import logger
import random
@@ -98,14 +99,15 @@ def mod_image_repeat_rows(
img.save(out_name)
-def add_date(img_path, out_name="image.jpg", bottom_offset=0,date=None,time=None):
+def add_date(img_path, out_name="image.jpg", bottom_offset=0,date=None,time="00:00"):
if date==None:
date_obj = datetime.now()
date_str_1 = date_obj.strftime("%p %H:%M")
date_str_2 = date_obj.strftime("%b. %d %Y")
else:
date_obj = datetime.strptime(date, '%Y/%m/%d')
- date_str_1 = date_obj.strftime("%p %H:%M")
+ date_obj2 = datetime.strptime(time,'%H:%M')
+ date_str_1 = date_obj2.strftime("%p %H:%M")
date_str_2 = date_obj.strftime("%b. %d %Y")
corner_offset = 50
img = Image.open(img_path)
@@ -155,40 +157,28 @@ if __name__ == "__main__":
"""
-def generateVHSStyle(infile, outfile, silence=False,date=None):
- if silence:
- cut_rows = bool(random.getrandbits(1))
- offset = random.choice([0, 5, 10])
- offset_hue(infile, "saturated.jpg")
- if cut_rows:
- mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
- else:
- mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
- add_date("shifted.jpg", "noisy.jpg",date=date)
- add_date("noisy.jpg", outfile, bottom_offset=offset)
- os.remove("shifted.jpg")
- os.remove("saturated.jpg")
- os.remove("noisy.jpg")
+def generateVHSStyle(infile, outfile, verbose=True,date=None,time="00:00"):
+ if not verbose:
+ logzero.loglevel(level=0)
+ cut_rows = bool(random.getrandbits(1))
+ offset = random.choice([0, 5, 10, 15, 20, 25])
+ logger.info("Saturating the image")
+ offset_hue(infile, "saturated.jpg")
+ if cut_rows:
+ logger.info("Shifting the image")
+ mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
else:
- cut_rows = bool(random.getrandbits(1))
- offset = random.choice([0, 5, 10, 15, 20, 25])
- logger.info("Saturating the image")
- offset_hue(infile, "saturated.jpg")
- if cut_rows:
- logger.info("Shifting the image")
- mod_image_repeat_rows("saturated.jpg", 0.012, 50, 10, True, "shifted.jpg")
- else:
- logger.info("Not applying lines effect")
- mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
- logger.info("Adding noise")
- add_date("shifted.jpg", "noisy.jpg",date=date)
- logger.info("Adding text")
- add_date("noisy.jpg", outfile, bottom_offset=offset)
- logger.info("Generated Image: out.jpg")
- logger.info("Removing residual files")
- os.remove("shifted.jpg")
- os.remove("saturated.jpg")
- os.remove("noisy.jpg")
+ logger.info("Not applying lines effect")
+ mod_image_repeat_rows("saturated.jpg", 0, 0, 0, True, "shifted.jpg")
+ logger.info("Adding noise")
+ add_date("shifted.jpg", "noisy.jpg",date=date,time=time)
+ logger.info("Adding text")
+ add_date("noisy.jpg", outfile, bottom_offset=offset,date=date,time=time)
+ logger.info("Generated Image")
+ logger.info("Removing residual files")
+ os.remove("shifted.jpg")
+ os.remove("saturated.jpg")
+ os.remove("noisy.jpg")
# generateVHSStyle("s.jpg","o.jpg")
diff --git a/src/VHSVideo.py b/src/VHSVideo.py
index 7e23ad0..88c065f 100644
--- a/src/VHSVideo.py
+++ b/src/VHSVideo.py
@@ -17,7 +17,7 @@ def SaveVid(path):
count += 1
-def Style(pathToFrames):
+def Style(pathToFrames,date=None,time="00:00"):
files = [f for f in os.listdir(pathToFrames) if isfile(join(pathToFrames, f))]
count = 0
for i in files:
@@ -26,7 +26,7 @@ def Style(pathToFrames):
fi = pathToFrames + f
out = fi + ".jpg"
- generateVHSStyle(fi, out, silence=True)
+ generateVHSStyle(fi, out, verbose=False,date=date,time=time)
os.rename(out, fi)
print("--------")
print("On Frame: ")
@@ -74,7 +74,7 @@ def generateVideo(outfile, path, infile):
out.release()
-def VHS_Vid(infile, outfile):
+def VHS_Vid(infile, outfile,date=None,time="00:00"):
path = "./frames/"
os.system("rm frames/*")
os.system("mkdir frames")
@@ -84,7 +84,7 @@ def VHS_Vid(infile, outfile):
except:
logger.debug("Extracted Frames")
logger.info("Applying A E S T H E T I C S")
- Style(path)
+ Style(path,date=date,time=time)
logger.info("Generating Vidio")
generateVideo("temp.mp4", path, infile)
logger.info("Extracting audio of original video")