PHP Classes

File: examples/case-studies/files/images/encrypted_image_archiver.md

Recommend this page to a friend!
  Packages of Christos Drogidis   Ascoos OS   examples/case-studies/files/images/encrypted_image_archiver.md   Download  
File: examples/case-studies/files/images/encrypted_image_archiver.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change: Update of examples/case-studies/files/images/encrypted_image_archiver.md
Date: 8 months ago
Size: 2,885 bytes
 

Contents

Class file image Download

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: - encrypted_image_archiver.php: Includes image processing, encryption, analysis, and reporting.

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.