Usage Instructions: Images
Using Munee, you can resize/crop/stretch/fill images on-the-fly using a set of arguments. The resulting image will be cached and served up on subsequent requests. If the source image is modified, it will recreate the cache and invalidate the client side cache and force the browser to download the newest version.
When using an on-the-fly image resizing tool like this, there is an inherent risk that someone will try and exploit it to try and resize a photo a thousand different ways to take down your server.
Munee has a couple of ways to minimise this risk a great deal. One is it checks that the referer is set and is coming from the same domain that the image is located on. Another is it only allows 3 resizes of an image within a 5 minute time span. Both of these features can be either turned off or changed within the dispatcher settings.
These options can be set in the first parameter of the
Request class in the dispatcher file. For example:
echo \Munee\Dispatcher::run(new \Munee\Request(array('image' => array('checkReferrer' => false))));
||Check to make sure the referer matches the same domain where the image is hosted|
||How many filters can be done within the
||Number of seconds before another resize can happen after the
||Which image processor to use. Values can be:
||Setup placeholders to be used for any images are missing. Placeholder services like http://placedog.com can be used as well. Examples can be found below.|
||Arguments||The resize filter can resize/crop/fill images.|
||Integer||N/A||The max height you want the image.|
||Integer||N/A||The max width you want the image.|
||Crop the image to the exact
||Stretch the image to match the exact
||Draw a background the exact size of the
||HEX Colour (without #)||
||This works in conjunction with
||JPEG compression value.|
Note: Boolean arguments can use
truthy values and
Resize an image to a specific width and keep it's correct aspect ratio. Note: This is using the long form of the arguments.
Resize an image and keep it's correct aspect ratio but neither width or height can be bigger than specified.
Crop an image to an exact size. If the image is smaller than the provided dimensions, it will not stretch or fill the image out to match the height and width. Note: This is using the shortened form of the arguments.
Crop an image and stretch it to an exact size.
Resize an image and put it on dark grey background the exact size of the dimensions.
||HEX Color (without #)||Applies the Imagine Colorize Effect.|
This would put a red overlay on the image.
||Applies the Imagine Grayscale Effect.|
This would convert the image to grayscale.
||Applies the Imagine Negative Effect.|
This would covert the image to it's negative form.
A new feature in Munee is being able to use image placeholders for missing images. This is a great feature to have if you are designer just starting a new site and don't necessarily have all of your images available. You can specify a specific image or use one of the numerous image placeholder websites out there like http://placedog.com.
You can also specify different image paths for different placeholder images as well. So if you want a different image for all of your /img/category/* images and another for all of your /img/product/* images, it's very easy to do.
Note: When specifying which images on your site you want to use placeholders for, you can use a wildcard (*) reference.
// Use a specific image for all missing images. echo \Munee\Dispatcher::run( new \Munee\Request(array( 'image' => array( 'placeholders' => array( '*' => WEBROOT . DS . 'img' . DS . 'placeholder-image.jpg' ) ) )) );
/** * Use a placeholder for all generic images, a specific placeholder for product images, * and a placeholder service for category images. * /img/category/missing-image.jpg --> Pulls in a random puppy image * /img/product/missing-image.jpg --> Uses /img/missing-product.image.jpg * /img/wherever-else/missing-image.jpg --> Uses /img/placeholder-image.jpg */ echo \Munee\Dispatcher::run( new \Munee\Request(array( 'image' => array( 'placeholders' => array( '/category/*' => 'http://placedog.com/1024/768', '/product/*' => WEBROOT . DS . 'img' . DS . 'missing-product-image.jpg', '*' => WEBROOT . DS . 'img' . DS . 'placeholder-image.jpg' ) ) )) );