2017 © Pedro Peláez
 

project dynamic-image

Dynamic image loading script that generates images of the requested size on the fly.

image

drroach/dynamic-image

Dynamic image loading script that generates images of the requested size on the fly.

  • Friday, June 22, 2018
  • by DrRoach
  • Repository
  • 4 Watchers
  • 11 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 33 % Grown

The README.md

DynamicImage

Logo, (*1)

Create dynamically sized images on the fly so that they don't need to be resized when added or uploaded., (*2)

The goal of this script is to allow images to be generated on the fly to any size. This is done by using PHPs imagick libraries to creating images in a fraction of a second., (*3)

This script has a fully functioning file based cache system which renews when original images are updated. Images are generated to scale and generated to high resolution. There is also support for images that are hosted on seperate endpoints., (*4)

JPG, JPEG, PNG and GIF images are supported., (*5)

Params

The parameters are expected as a key, value array and passed when the object is created., (*6)

filename - required This is the original image filename including it's extension, for example, snorkel.jpg. This image can be of any size any will be rendered in near perferct resolution., (*7)

width - required This is the desired width of the image., (*8)

height - required This is the desired height of the image., (*9)

image_directory - This is the directory that all of your original images are held in. This cannot move 'up' through your filesystem to keep the script as a whole, more secure. This MUST also end with a trailing slash., (*10)

debug - If you wish for errors to be turned on, then you can set this to true to display any errors that may be occuring., (*11)

image_missing - If the requested image isn't found then this image is returned instead. This means that you never get a blank response and there's always something that you can display., (*12)

exceptions - Parameter to set whether or not you wish for exceptions to be thrown by the script. The default value is false so if you want exceptions to be thrown then you must set this to true when creating the object., (*13)

validate_image - Flag to indicate whether or not you want to check for the requested images' existance before looking to see if the image exists in cache. This means that if the image gets updated after it's been saved to cache then the image wont be regenerated. By default this is set to true., (*14)

invalidate_cache - Parameter to set whether or not the cache image should be invalidated after x amount of seconds. This means you can re-generate cache images every day for example., (*15)

Example AJAX request to load an image from a seperate domain

Request URL, (*16)

http://yousite.com/loadimage.php?filename=snorkel.jpg&width=500&height=500, (*17)

loadimage.php, (*18)

 $_GET['filename'],
    'width' => $_GET['width'],
    'height' => $_GET['height']
];

$DI = new DynamicImage($settings);
echo json_encode($DI->file);
?>

HTML, (*19)

<img src="<?=$DI->file;?>">

If you have your images saved in a seperate folder, such as /images, you can set Dynamic Images to use that folder like so:, (*20)

 $_GET['filename'],
    'width' => $_GET['width'],
    'height' => $_GET['height'],
    'image_directory' => 'images/'
];

$DI = new DynamicImage($settings);
echo json_encode($DI->file);
?>

Potential Issues

Make sure that your cache folder is writable and that the apache user has permission to write on your machine. Usually user www-data., (*21)

The Versions

22/06 2018

dev-master

9999999-dev

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

23/08 2017

dev-hotfix/intCheck

dev-hotfix/intCheck

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

23/08 2017

v0.2.3

0.2.3.0

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

23/08 2017

dev-hotfix/invalidWidthOrHeight

dev-hotfix/invalidWidthOrHeight

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

23/08 2017

v0.2.2

0.2.2.0

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

23/08 2017

v0.2.1

0.2.1.0

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

09/08 2017

dev-feature/githubio

dev-feature/githubio

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

09/08 2017

dev-dev

dev-dev

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas

08/08 2017

v0.2

0.2.0.0

Dynamic image loading script that generates images of the requested size on the fly.

  Sources   Download

The Development Requires

by Ryan Deas