from aspose.imaging import Image
from aspose.imaging.imageoptions import PngOptions
from aspose.imaging.fileformats.png import PngColorType
import os


if 'TEMPLATE_DIR' in os.environ:
	templates_folder = os.environ['TEMPLATE_DIR']
else:
	templates_folder = r"C:\Users\USER\Downloads\templates"

delete_output = 'SAVE_OUTPUT' not in os.environ
data_dir = templates_folder

png_options = PngOptions()
png_options.color_type = PngColorType.GRAYSCALE

output_options = {
	os.path.join(data_dir, "output.svg"): None,
	os.path.join(data_dir, "output.png"): png_options
}

with Image.load(os.path.join(data_dir, "template.eps")) as image:
	for key, options in output_options.items():
		if options is None:
			image.save(key)
		else:
			image.save(key, options)
			
if delete_output:
	for file in output_options:
		os.remove(file)