Skip to content

Commit 3c378bc

Browse files
author
Evgeniy Sidenko
committed
Updated upto the version 23.10
1 parent 79f7d4a commit 3c378bc

File tree

2 files changed

+18
-55
lines changed

2 files changed

+18
-55
lines changed
Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import aspose.pycore as aspycore
2-
from aspose.imaging.imageoptions import PngOptions
3-
from aspose.imaging.fileformats.eps import *
4-
from aspose.imaging.fileformats.eps.consts import *
2+
from aspose.imaging.fileformats.eps import EpsImage
53
from aspose.imaging import Image
64
import os
75

@@ -24,35 +22,18 @@ def get_data_root_dir_local():
2422
data_dir = os.path.join(get_data_root_dir(), 'ModifyingAndConvertingImages')
2523
output_path = os.path.join(get_output_dir(), "anyEpsFile.png")
2624
print("Running example SupportForEPSFormat")
25+
26+
eps_preview_files = []
2727
with aspycore.as_of(Image.load(os.path.join(data_dir, "sample.eps")),
2828
EpsImage) as eps_image:
29-
# check if EPS image has any raster preview to proceed (for now only raster preview is supported)
30-
if eps_image.has_raster_preview:
31-
if eps_image.photoshop_thumbnail is not None:
32-
pass
33-
34-
if eps_image.eps_type == EpsType.INTERCHANGE:
35-
# Get EPS Interchange subformat instance
36-
eps_interchange_image = aspycore.as_of(eps_image, EpsInterchangeImage)
37-
if eps_interchange_image.raster_preview is not None:
38-
print("Has raster_preview")
39-
pass
40-
else:
41-
# Get EPS Binary subformat instance
42-
eps_binary_image = aspycore.as_of(eps_image, EpsBinaryImage)
43-
if eps_binary_image.tiff_preview is not None:
44-
print("Has tiff_preview")
45-
pass
46-
47-
if eps_binary_image.wmf_preview is not None:
48-
print("Has wmf_preview")
49-
pass
50-
51-
# export EPS image to PNG (by default, best available quality preview is used for export)
52-
eps_image.save(output_path, PngOptions())
29+
for preview in eps_image.get_preview_images():
30+
previewPath = os.path.join(data_dir, "output." + preview.file_format.name.lower())
31+
preview.save(previewPath)
32+
eps_preview_files.append(previewPath)
5333

5434
if 'SAVE_OUTPUT' not in os.environ:
55-
if os.path.exists(output_path):
56-
os.remove(output_path)
35+
for output_path in eps_preview_files:
36+
if os.path.exists(output_path):
37+
os.remove(output_path)
5738

5839
print("Finished example SupportForEPSFormat")
Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import 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
74
import os
85

96

@@ -24,29 +21,14 @@ def get_data_root_dir_local():
2421
print("Running example ExportEps")
2522
# The path to the documents directory.
2623
data_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+
3026
with 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

4731
if '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

5234
print("Finished example ExportEps")

0 commit comments

Comments
 (0)