I am trying to get this to create the .jpg without the .png in the file name.
This does convert successfully to .jpg but the filename is mangled.
This line is the problem. target_name = "sys.argv[1] - 4" + ".jpg"
import os
import sys
from PIL import Image
if len(sys.argv) > 1:
if os.path.exists(sys.argv[1]):
im = Image.open(sys.argv[1])
# Need to backspace 4 times
target_name = "sys.argv[1] - 4" + ".jpg"
# Saved as sys.argv[1] - 4.jpg
rgb_im = im.convert('RGB')
rgb_im.save(target_name)
print("Saved as " + target_name)
else:
print(sys.argv[1] + " not found")
else:
print("Usage: convert2jpg.py <file>")
again, you fail to show input/expected output/actual output./issues faced.
again, ... reflect on posting questions by imagining that (only) you were asked to answer with the information provided, would it be enough to respond without asking for further clarification/information ..... if not then post enough detail for a reasoned to be expected not requests for additional information/clarification.