|
@@ -55,6 +55,13 @@ async def convert_eps_to_svg(file: UploadFile):
|
|
raise HTTPException(status_code=400, detail="Only EPS files are accepted")
|
|
raise HTTPException(status_code=400, detail="Only EPS files are accepted")
|
|
|
|
|
|
try:
|
|
try:
|
|
|
|
+ # Ensure directories exist and are writable
|
|
|
|
+ for directory in [UPLOAD_DIR, PROCESSED_DIR]:
|
|
|
|
+ if not os.path.exists(directory):
|
|
|
|
+ os.makedirs(directory, exist_ok=True)
|
|
|
|
+ if not os.access(directory, os.W_OK):
|
|
|
|
+ raise HTTPException(status_code=500, detail=f"Directory {directory} is not writable")
|
|
|
|
+
|
|
# Save uploaded file
|
|
# Save uploaded file
|
|
input_path = os.path.join(UPLOAD_DIR, file.filename)
|
|
input_path = os.path.join(UPLOAD_DIR, file.filename)
|
|
with open(input_path, "wb") as f:
|
|
with open(input_path, "wb") as f:
|
|
@@ -66,7 +73,14 @@ async def convert_eps_to_svg(file: UploadFile):
|
|
final_svg = os.path.join(PROCESSED_DIR, f"{base_name}.svg")
|
|
final_svg = os.path.join(PROCESSED_DIR, f"{base_name}.svg")
|
|
|
|
|
|
# Convert EPS to SVG
|
|
# Convert EPS to SVG
|
|
- subprocess.run(['eps2svg', input_path, temp_svg], check=True)
|
|
|
|
|
|
+ try:
|
|
|
|
+ subprocess.run(['eps2svg', input_path, temp_svg], check=True, capture_output=True, text=True)
|
|
|
|
+ except subprocess.CalledProcessError as e:
|
|
|
|
+ raise HTTPException(status_code=500, detail=f"eps2svg conversion failed: {e.stderr}")
|
|
|
|
+
|
|
|
|
+ # Check if temp_svg was created
|
|
|
|
+ if not os.path.exists(temp_svg):
|
|
|
|
+ raise HTTPException(status_code=500, detail="eps2svg failed to create output file")
|
|
|
|
|
|
# Try to optimize SVG using scour
|
|
# Try to optimize SVG using scour
|
|
try:
|
|
try:
|