Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run():
if Data.image_path == "":
output_label["text"] = "Choose the image file first."
return
if os.access("{}/AppIcon.appiconset".format(Data.save_path), os.W_OK) == False:
os.mkdir("{}/AppIcon.appiconset".format(Data.save_path))
file = open("{}/AppIcon.appiconset/Contents.json".format(Data.save_path), mode="w")
json.dump(json_data, file, indent=4, sort_keys=True, separators=(',', ':'))
file.close()
with open("{}/AppIcon.appiconset/Contents.json".format(Data.save_path), mode="r") as data_file:
data = json.load(data_file)
images = data["images"]
try:
im = Image.open(Data.image_path)
output_label["text"] = "Image specs: {} {} {}\n{}\n".format(im.format, im.size, im.mode, "-"*35)
for image in images:
size = get_size(image)
out = im.resize(size, Image.ANTIALIAS)
out.save("{}/AppIcon.appiconset/{}".format(Data.save_path, image["filename"]), format="PNG")
output_label["text"] += "Image generated: {}\n".format(size)
open_saved_button.grid(row=1, column=0, columnspan=2, sticky=tk.W+tk.E)
except IOError:
output_label["text"] = "Please select a supported image file."
def get_save_path():
Data.save_path = askdirectory()
chosen_save_path_label["text"] = Data.save_path
return Data.save_path
def clear():
Data.image_path = ""
Data.save_path = os.path.dirname(__file__)
output_label["text"] = ""
chosen_file_path_label["text"] = ""
chosen_save_path_label["text"] = ""
open_saved_button.grid_remove()
if ".app" in Data.save_path:
while not Data.save_path.endswith(".app"):
Data.save_path = os.path.dirname(Data.save_path)
def get_save_path():
Data.save_path = askdirectory()
chosen_save_path_label["text"] = Data.save_path
return Data.save_path
def clear():
Data.image_path = ""
Data.save_path = os.path.dirname(__file__)
output_label["text"] = ""
chosen_file_path_label["text"] = ""
chosen_save_path_label["text"] = ""
open_saved_button.grid_remove()
if ".app" in Data.save_path:
while not Data.save_path.endswith(".app"):
Data.save_path = os.path.dirname(Data.save_path)
def get_save_path():
Data.save_path = askdirectory()
chosen_save_path_label["text"] = Data.save_path
return Data.save_path
def clear():
Data.image_path = ""
Data.save_path = os.path.dirname(__file__)
output_label["text"] = ""
chosen_file_path_label["text"] = ""
chosen_save_path_label["text"] = ""
open_saved_button.grid_remove()
if ".app" in Data.save_path:
while not Data.save_path.endswith(".app"):
Data.save_path = os.path.dirname(Data.save_path)