Uncategorized

Imagee – Secure Upload, Processing, Storage, Serve (Images and Media)

By Acty, February 5, 2014

The Imagee library is designed as a simple plug and play class allowing you to develop
powerful applications, without worrying about the security of your uploads. Imagee is
the secure upload, storage, processing and serving library.

Key features:

  • Secure Image upload
  • Secure Image storage & serving to user
  • Handles XHR and conventional POST upload methods
  • Flexible usage (see examples below)
  • Powerful post processing
  • Lightweight (only 3.5K lines of code)
  • Comes pre-configured with an AJAX upload plugin
  • Automatically watermark/resize/orientation fix images upon upload
  • Restrict uploads by image size & file size
  • Option to enforce the max dimensions of the image by shrinking them if they are too
    large

Post-processing features include:

  • Addition of text or image watermark with custom fonts (.otf & .ttf), colours,
    angle, positioning and opacity
  • Add filters such as;
    • Sepia
    • Grayscale
    • Edge Detect
    • Gaussian Blur
    • Mean Removal
    • Smooth
    • Negative
  • Adjust brightness of the image
  • Adjust contrast of the image
  • Colourise images, custom colours can be specified as a HEX value. Pre-set colours
    include;

    • Pink
    • Green
    • Purple
    • Yellow
    • Blue
    • Red
  • Crop images
  • Rotate image by specified degrees
  • Resize (with option to resize proportionally – this avoids the squashing/stretching
    that can occur during a conventional resize operation)
  • Create thumbnails (resized proportionally then cropped to the correct size)
  • Compress the file size of the image
  • Correct the orientation of the image automatically based on Exif data (if needed)

Image upload example

<?php
    include_once 'Imagee.php';
    $Imagee = new Imagee;
    $Imagee->SimpleUpload('file');
?> 

Miscellaneous functions:

We have included some helpful file system functions to make your life even easier,
these include;

  • Copy
  • Move
  • Delete
  • Download – force download of the image in the users browser

Flexible usage

All post processing functions in the library can take the input of an image resource
or file name. Each function can also overwrite, create a new image, or simply return the
modified image resource. This allows you to continue working on the image without
opening and closing it multiple times – this helps decrease execution speed
dramatically. These features are best explained through examples such as the two
below.

Example usage (Simple):

<?php
    include_once 'Imagee.php';
    $Imagee = new Imagee;
    $Imagee->ApplyFilter('path/to/image.gif', 'Sepia');
?> 

Example usage (Multiple):

<?php
    include_once 'Imagee.php';
    $Imagee = new Imagee;

    list($Resource, $MIME) = $Imagee->Open('path/to/image.jpg');

    $Resource = $Imagee->ApplyFilter($Resource, 'Sepia', NULL, NULL, $MIME);
    $Resource = $Imagee->ChangeBrightness($Resource, 10, NULL, $MIME);
    $Resource = $Imagee->AddWaterMark($Resource, NULL, $MIME);
    $Imagee->Save($Resource, 'NewImage.jpg', $MIME);
?> 

Requirements:

  • Operating System: Linux
  • Web server: Apache
  • PHP version 5 and above
  • PHP GD library

Files included:

  • Imagee.php (class contained in this one file)
  • view.php (used to display images securely)
  • Files associated to front end uploader
  • Documentation presented in a HTML file