Skip to content

Latest commit

 

History

History
63 lines (53 loc) · 2.82 KB

File metadata and controls

63 lines (53 loc) · 2.82 KB

Encrypted Image Archiver

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.

Purpose

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.

Structure

The case study is implemented in a single PHP file:

Prerequisites

  1. Install Ascoos OS (main repository).
  2. Ensure write permissions for $AOS_LOGS_PATH and $AOS_TMP_DATA_PATH/image_archiver/.
  3. Place input files (xray.jpg, watermark.png) in the input/ folder.
  4. The font Murecho-Regular.ttf must be available at $AOS_FONTS_PATH/Murecho/.
  5. The phpBCL8 library is preinstalled and auto-loaded.

Getting Started

  1. Verify that input images exist in the input/ folder.
  2. Run the script via web server:
    https://localhost/aos/examples/case-studies/files/images/encrypted_image_archiver.php
    

Example Usage

$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');

Expected Output

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

Resources

Contributing

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.

License

This case study is licensed under the Ascoos General License (AGL). See LICENSE.