| skipped 10 lines |
11 | 11 | | from reportlab.pdfgen import canvas |
12 | 12 | | from reportlab.lib.pagesizes import B5 |
13 | 13 | | |
| 14 | + | |
| 15 | + | def make_jpeg(file_path, text): |
| 16 | + | image = Image.new('RGB', (729, 516), (255, 255, 255)) # B5, White |
| 17 | + | draw = ImageDraw.Draw(image) |
| 18 | + | draw.text((10, 10), text, fill=(0, 0, 0)) # Black |
| 19 | + | image.save(file_path, format='jpeg') |
| 20 | + | |
14 | 21 | | def make_png(file_path, text, byte_size): |
15 | 22 | | image = Image.new('RGB', (729, 516), (255, 255, 255)) # B5, White |
16 | 23 | | draw = ImageDraw.Draw(image) |
| skipped 42 lines |
59 | 66 | | def parse_args(): |
60 | 67 | | colorama.init(autoreset=True) |
61 | 68 | | parser = argparse.ArgumentParser(description='Create a dummy file of the specified size.') |
62 | | - | parser.add_argument('-n', '--name', help='File name(.png, .pdf)', required=True) |
| 69 | + | parser.add_argument('-n', '--name', help='File name(.jpeg, .png, .pdf)', required=True) |
63 | 70 | | parser.add_argument('-t', '--text', help='Text to be written in the file') |
64 | | - | parser.add_argument('-s', '--size', help='Bytes of file(png only)', type=int) |
| 71 | + | parser.add_argument('-s', '--size', help='Bytes of file(.png only)') |
65 | 72 | | args = parser.parse_args() |
66 | 73 | | # if args.name.endswith('.png'): |
67 | 74 | | |
68 | 75 | | if __name__ == '__main__': |
69 | 76 | | colorama.init(autoreset=True) |
70 | | - | make_pdf('dummy.pdf', 'sample pdf') |
| 77 | + | make_jpeg('dummy.jpeg', 'sample text') |
71 | 78 | | |