File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 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." )
You can’t perform that action at this time.
0 commit comments