11import aspose .pycore as aspycore
2- from aspose .imaging import Image , PdfComplianceVersion
3- from aspose .imaging .imageoptions import TiffOptions , PdfOptions
4- from aspose .imaging .fileformats .tiff .enums import TiffExpectedFormat
5- from aspose .imaging .fileformats .eps import EpsImage , EpsPreviewFormat , EpsBinaryImage
6- from aspose .imaging .fileformats .pdf import PdfCoreOptions
2+ from aspose .imaging import Image
3+ from aspose .imaging .fileformats .eps import EpsImage , EpsPreviewFormat
74import os
85
96
@@ -24,29 +21,14 @@ def get_data_root_dir_local():
2421print ("Running example ExportEps" )
2522# The path to the documents directory.
2623data_dir = os .path .join (get_data_root_dir (), 'eps' )
27- out_file1 = os .path .join (get_output_dir (), "Sample.pdf" )
28- out_file2 = os .path .join (get_output_dir (), "Sample1.tiff" )
29- out_file3 = os .path .join (get_output_dir (), "Sample2.tiff" )
24+ out_file = os .path .join (get_output_dir (), "Sample.tiff" )
25+
3026with aspycore .as_of (Image .load (os .path .join (data_dir , "Sample.eps" )), EpsImage ) as image :
31- obj_init = PdfCoreOptions ()
32- obj_init .pdf_compliance = PdfComplianceVersion .PDF_A1B
33- options = PdfOptions ()
34- options .pdf_core_options = obj_init
35- image .preview_to_export = EpsPreviewFormat .POST_SCRIPT_RENDERING
36- image .save (out_file1 , options )
37-
38- with aspycore .as_of (Image .load (os .path .join (data_dir , "Sample.eps" )), EpsBinaryImage ) as image :
39- # Tiff image export options
40- options = TiffOptions (TiffExpectedFormat .TIFF_JPEG_RGB )
41- # The first way:
42- image .tiff_preview .save (out_file2 , options )
43- # The second way:
44- image .preview_to_export = EpsPreviewFormat .TIFF
45- image .save (out_file3 , options )
27+ tiffPreview = image .get_preview_image (EpsPreviewFormat .TIFF )
28+ if tiffPreview is not None :
29+ tiffPreview .save (out_file )
4630
4731if 'SAVE_OUTPUT' not in os .environ :
48- os .remove (out_file1 )
49- os .remove (out_file2 )
50- os .remove (out_file3 )
32+ os .remove (out_file )
5133
5234print ("Finished example ExportEps" )
0 commit comments