This case study demonstrates how Ascoos OS can be used to securely process and archive images. The system resizes and watermarks input images, encrypts them, analyzes file sizes, and generates a visual report.
This example uses the following Ascoos OS classes:
- TImagesHandler: Loads, resizes, and watermarks images.
- TFilesHandler: Saves and encrypts files, checks quota.
- TEventHandler: Logs events for transparency and debugging.
- TArrayAnalysisHandler: Analyzes file sizes.
- TArrayGraphHandler: Generates bar chart of file size comparison.
The case study is implemented in a single PHP file:
encrypted_image_archiver.php: Includes image processing, encryption, analysis, and reporting.
- Install Ascoos OS (main repository).
- Ensure write permissions for
$AOS_LOGS_PATHand$AOS_TMP_DATA_PATH/image_archiver/. - Place input files (
xray.jpg,watermark.png) in theinput/folder. - The font
Murecho-Regular.ttfmust be available at$AOS_FONTS_PATH/Murecho/. - The phpBCL8 library is preinstalled and auto-loaded.
- Verify that input images exist in the
input/folder. - Run the script via web server:
https://localhost/aos/examples/case-studies/files/images/encrypted_image_archiver.php
$processedImage = $imagesHandler->resize($imageData, 800, 600);
$processedImage = $imagesHandler->addWatermark($processedImage, $watermarkData, 10, 10, 0.5);
$imagesHandler->saveToFile($processedImage, $outputImage);
$filesHandler->encryptFile($outputImage, $encryptedImage, "AscoosSecretKey");
$graphHandler->setArray([$originalSize, $processedSize, $encryptedSize]);
$graphHandler->createBarChart('image_size_chart.png');The script generates a processed image, an encrypted copy, and a bar chart comparing file sizes. Example output:
{
"original": "/tmp/input/xray.jpg",
"processed": "/image_archiver/image_20250828_230900.jpg",
"encrypted": "/image_archiver/image_20250828_230900.enc",
"chart": "/image_archiver/image_size_chart.png"
}Want to contribute to this case study? Fork the repository, modify or extend encrypted_image_archiver.php, and submit a pull request. See CONTRIBUTING.md for guidelines.
This case study is licensed under the Ascoos General License (AGL). See LICENSE.