|
| 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