| skipped 16 lines |
17 | 17 | | draw = ImageDraw.Draw(image) |
18 | 18 | | draw.text((10, 10), text, fill=(0, 0, 0)) # Black |
19 | 19 | | image.save(file_path, format='jpeg') |
| 20 | + | return True |
20 | 21 | | |
21 | 22 | | def make_png(file_path, text, byte_size): |
22 | 23 | | image = Image.new('RGB', (729, 516), (255, 255, 255)) # B5, White |
| skipped 39 lines |
62 | 63 | | c.drawString(15, 40, text) |
63 | 64 | | c.showPage() |
64 | 65 | | c.save() |
| 66 | + | return True |
65 | 67 | | |
66 | 68 | | def parse_bytes(byte_str): |
67 | 69 | | if byte_str == None: |
| skipped 24 lines |
92 | 94 | | args = parser.parse_args() |
93 | 95 | | if args.file_path.endswith('.jpeg') or args.file_path.endswith('.jpg'): |
94 | 96 | | make_jpeg(args.file_path, args.text) |
| 97 | + | print(Fore.GREEN + 'Successfully generated' + args.file_path) |
| 98 | + | |
95 | 99 | | elif args.file_path.endswith('.png'): |
96 | | - | make_png(args.file_path, args.text, parse_bytes(args.bytes)) |
| 100 | + | if make_png(args.file_path, args.text, parse_bytes(args.bytes)): |
| 101 | + | print(Fore.GREEN + 'Successfully generated' + args.file_path) |
| 102 | + | else: |
| 103 | + | print(Fore.RED + 'Failed to generate file.') |
| 104 | + | |
97 | 105 | | elif args.file_path.endswith('.pdf'): |
98 | 106 | | make_pdf(args.file_path, args.text) |
| 107 | + | print(Fore.GREEN + 'Successfully generated' + args.file_path) |
| 108 | + | |
99 | 109 | | else: |
100 | 110 | | print(Fore.RED + 'Error: Invalid file extension.') |
101 | 111 | | |
| skipped 1 lines |