|
| 1 | +# GROUP: MODIFYING_AND_CONVERTING_IMAGES |
| 2 | + |
| 3 | +from aspose.pycore import as_of |
| 4 | +from aspose.imaging import Image, RasterImage |
| 5 | +import os |
| 6 | + |
| 7 | + |
| 8 | +# Initialization |
| 9 | +def get_data_root_dir_local(): |
| 10 | + if 'BASE_DIR' in os.environ: |
| 11 | + return os.environ["BASE_DIR"] |
| 12 | + return "." |
| 13 | + |
| 14 | + |
| 15 | +if 'get_data_root_dir' not in dir(): |
| 16 | + get_data_root_dir = get_data_root_dir_local |
| 17 | + |
| 18 | +# Example code: |
| 19 | +# The path to the documents directory. |
| 20 | +data_dir = os.path.join(get_data_root_dir(), 'png') |
| 21 | + |
| 22 | +# Signing limitations: |
| 23 | +# - The LSB steganography algorithm requires the image to be at least 8 pixels in width and height, with a minimum of 16,384 total pixels. |
| 24 | +# - Password must be at least 4 characters long. |
| 25 | +# |
| 26 | +# var password = "1234"; |
| 27 | +# var filePath = "c:\sunflower.jpg"; |
| 28 | +# |
| 29 | +##################################### Example 1 ############################ |
| 30 | +# Faster checking method with partial data extraction. # |
| 31 | +# Set detectionThreasholdPercentage value to 75% (default value). # |
| 32 | +############################################################################ |
| 33 | + |
| 34 | +password = "123456" |
| 35 | + |
| 36 | +with as_of(Image.load(os.path.join(data_dir, "00020.png")), RasterImage) as image: |
| 37 | + image.embed_digital_signature(password) |
| 38 | + isSigning = image.is_digital_signed(password, -1) |
| 39 | + print(f"Check signing result of file is: {isSigning}") |
0 commit comments