Skip to content

Commit f984472

Browse files
author
Evgeniy Sidenko
committed
Updated upto 23.7
1 parent dd74368 commit f984472

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Examples/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ This repository contains Python examples for [Aspose.Imaging for Python via .NET
99
- Run **python RunExamples.py** file, all the examples are called from here.
1010
- Specify group of examples or test file filter you want to run or call needed example manually writing code for it.
1111

12+
## The command line arguments
13+
14+
Using the following arguments you can manage the process of examples running.
15+
`python RunExamples.py [--argument value] [--argument value] ...`
16+
**Arguments:**
17+
18+
| Argument | Value |
19+
| :- | :- |
20+
|`--src-dir`|`<path to the root example dir>`<br>Default: ./src|
21+
|`--data-dir`|`<path to the root data dir>`<br>Default: ./data|
22+
|`--output-dir`|`<path to the output dir>`<br>Default: ./output|
23+
|`--license`|`<path to a license file>`<br>Default: No license|
24+
|`--save-output`|`(true/false)`<br>Default: false|
25+
|`--groups`|`groups-flag`<br>**Can contains the following bit masks or combination**<br> 1 - Test drawing and formatting images <br> 2 - Test modifying and converting images <br> 4 - Test of memory strategies" <br> 8 - Test additional Aspose.Imaging features <br> 16 - Test file formats <br> **Default:** All |
26+
|`--file-filter`|`regex`<br>Default: All files|
27+
|--help|No need value|
28+
29+
1230
Please feel free to reach out using our Forums if you have any issues setting up or running the examples.
1331

1432
Visit [Aspose Documentation and Developer Guide](https://docs.aspose.com/imaging/python-net/how-to-run-the-examples/) for details.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# GROUP: MODIFYING_AND_CONVERTING_IMAGES
2+
import aspose.pycore as aspycore
3+
from aspose.imaging import Image, RasterImage, Point
4+
import os
5+
6+
7+
# Initialization
8+
def get_data_root_dir_local():
9+
if 'BASE_DIR' in os.environ:
10+
return os.environ["BASE_DIR"]
11+
return "."
12+
13+
14+
if 'get_data_root_dir' not in dir():
15+
get_data_root_dir = get_data_root_dir_local
16+
17+
if 'get_output_dir' not in dir():
18+
get_output_dir = get_data_root_dir_local
19+
20+
# Example code:
21+
# The path to the documents directory.
22+
data_dir = os.path.join(get_data_root_dir(), 'png')
23+
out_file = os.path.join(get_output_dir(), "blended.png")
24+
25+
print("Running example AddAlphaBlendingForImage")
26+
with aspycore.as_of(Image.load(os.path.join(data_dir, "image0.png")), RasterImage) as background:
27+
with aspycore.as_of(Image.load(os.path.join(data_dir, "aspose_logo.png")), RasterImage) as overlay:
28+
center = Point((background.width - overlay.width) // 2, (background.height - overlay.height) // 2)
29+
background.blend(center, overlay, overlay.bounds, 127)
30+
background.save(out_file)
31+
32+
if 'SAVE_OUTPUT' not in os.environ:
33+
os.remove(out_file)
34+
35+
print("Finished example ApplyFilterMethod")

0 commit comments

Comments
 (0)