File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Examples/src/modifyingandconvertingimages/png Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # GROUP: TEST_FILE_FORMATS
2
+
3
+ import aspose .pycore as aspycore
4
+ from aspose .imaging import Image
5
+ from aspose .imaging .imageoptions import PngOptions , PngCompressionLevel
6
+ import os
7
+
8
+
9
+ # Initialization
10
+ def get_data_root_dir_local ():
11
+ if 'BASE_DIR' in os .environ :
12
+ return os .environ ["BASE_DIR" ]
13
+ return "."
14
+
15
+
16
+ if 'get_data_root_dir' not in dir ():
17
+ get_data_root_dir = get_data_root_dir_local
18
+
19
+ if 'get_output_dir' not in dir ():
20
+ get_output_dir = get_data_root_dir_local
21
+
22
+ # Example code:
23
+ # The path to the documents directory.
24
+ data_dir = os .path .join (get_data_root_dir (), 'png' )
25
+
26
+ print ("Running example PngCompressionLevelExample" )
27
+
28
+ with Image .load (os .path .join (data_dir , "aspose_logo.png" )) as image :
29
+ for compression in range (11 ):
30
+ output_file = os .path .join (get_output_dir (), f"compressionTest{ compression } .png" )
31
+ out_options = PngOptions ()
32
+ out_options .png_compression_level = PngCompressionLevel (compression )
33
+ image .save (output_file , out_options )
34
+
35
+ if 'SAVE_OUTPUT' not in os .environ :
36
+ os .remove (output_file )
37
+
38
+ print ("Finished example PngCompressionLevelExample" )
You can’t perform that action at this time.
0 commit comments