Skip to content

Commit fe960a6

Browse files
authored
Create script.py
Script to convert JPEG file into PNG format
1 parent 541229b commit fe960a6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

JPEG to PNG/script.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import spire.xls as xls
2+
3+
def convert_jpeg_to_png(input_file_path, output_file_path):
4+
workbook = xls.Workbook()
5+
workbook.LoadFromFile(input_file_path)
6+
7+
# Convert JPEG to PNG by calling Workbook.save() method.
8+
workbook.save(output_file_path, Format=xls.ExcelFormat.PNG)
9+
10+
# Get the conversion result.
11+
conversion_result = workbook.SaveResult
12+
13+
return conversion_result
14+
15+
if __name__ == "__main__":
16+
input_file_path = "input.jpg"
17+
output_file_path = "output.png"
18+
19+
conversion_result = convert_jpeg_to_png(input_file_path, output_file_path)
20+
21+
if conversion_result:
22+
print("The JPEG file was successfully converted to PNG.")
23+
else:
24+
print("An error occurred while converting the JPEG file to PNG.")

0 commit comments

Comments
 (0)