jebin2 commited on
Commit
413ae2e
·
1 Parent(s): 9520870
Files changed (2) hide show
  1. __pycache__/main.cpython-313.pyc +0 -0
  2. main.py +18 -2
__pycache__/main.cpython-313.pyc CHANGED
Binary files a/__pycache__/main.cpython-313.pyc and b/__pycache__/main.cpython-313.pyc differ
 
main.py CHANGED
@@ -129,13 +129,21 @@ async def convert_image(
129
  to_format: str = Form(...)
130
  ):
131
  try:
 
 
 
 
132
  converter = Converter()
133
  output_path = converter.convert_image(id, to_format)
134
 
 
 
 
 
135
  # Return success response
136
  return JSONResponse({
137
  "success": True,
138
- "message": "Image uploaded successfully",
139
  "new_filename": output_path.split("/")[-1]
140
  })
141
 
@@ -157,13 +165,21 @@ async def remove_metadata(
157
  id: str = Form(...)
158
  ):
159
  try:
 
 
 
 
160
  removeMetadata = RemoveMetadata()
161
  output_path, metadata = removeMetadata.process(id)
162
 
 
 
 
 
163
  # Return success response
164
  return JSONResponse({
165
  "success": True,
166
- "message": "Image uploaded successfully",
167
  "new_filename": output_path.split("/")[-1],
168
  "other_info": metadata
169
  })
 
129
  to_format: str = Form(...)
130
  ):
131
  try:
132
+ # Check if input is SVG - PIL cannot read SVG files
133
+ if id.lower().endswith('.svg'):
134
+ raise ValueError("SVG files cannot be converted. SVG is only available as an output format.")
135
+
136
  converter = Converter()
137
  output_path = converter.convert_image(id, to_format)
138
 
139
+ # Check if conversion failed
140
+ if output_path is None:
141
+ raise ValueError("Image conversion failed. The file may be corrupted or in an unsupported format.")
142
+
143
  # Return success response
144
  return JSONResponse({
145
  "success": True,
146
+ "message": "Image converted successfully",
147
  "new_filename": output_path.split("/")[-1]
148
  })
149
 
 
165
  id: str = Form(...)
166
  ):
167
  try:
168
+ # Check if input is SVG - PIL cannot read SVG files
169
+ if id.lower().endswith('.svg'):
170
+ raise ValueError("SVG files cannot be processed. SVG is a vector format without embedded metadata.")
171
+
172
  removeMetadata = RemoveMetadata()
173
  output_path, metadata = removeMetadata.process(id)
174
 
175
+ # Check if processing failed
176
+ if output_path is None:
177
+ raise ValueError("Metadata removal failed. The file may be corrupted or in an unsupported format.")
178
+
179
  # Return success response
180
  return JSONResponse({
181
  "success": True,
182
+ "message": "Metadata removed successfully",
183
  "new_filename": output_path.split("/")[-1],
184
  "other_info": metadata
185
  })