From 862b0783d731dd8980698fb035b78300703b9076 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Tue, 10 Mar 2020 23:43:12 +0530 Subject: Added video generator --- src/VHSImage.py | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'src/VHSImage.py') diff --git a/src/VHSImage.py b/src/VHSImage.py index 51688b1..81f446d 100644 --- a/src/VHSImage.py +++ b/src/VHSImage.py @@ -146,25 +146,39 @@ if __name__ == "__main__": build_background("bkg.jpg", 25) """ -def generateVHSStyle(infile, outfile): - 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") +def generateVHSStyle(infile, outfile, silence=False): + if silence: + cut_rows = bool(random.getrandbits(1)) + offset = random.choice([0,5,10,15,20,25]) + 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") + add_date("noisy.jpg",outfile, bottom_offset=offset) + os.remove("shifted.jpg") + os.remove("saturated.jpg") + os.remove("noisy.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") - 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") + 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") + 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") #generateVHSStyle("s.jpg","o.jpg") \ No newline at end of file -- cgit v1.2.3