-
Notifications
You must be signed in to change notification settings - Fork 0
AMFImageRendering
Overview
The AMFImageRendering module has the goal to resize the images to the screen size of device. The module is well described in the next picture:
The AMFImageRendering working in this mode:
- Take ScreenWidth from AMFWURFLFilter or AMFWURFLFilterMemcached
- check if the image resized is not present in cache, if yes it will go at point 5
- load original image info
- resize the image and save it in cache directory
- show the image
Note: if the image is less of the screen size, the image will not resize. It’s possible to force this option
Prerequisite
AMFWURFLFilter,AMFWURFLFilter,AMFDetectRightFilter or AMFDetectRightFilter must be configured and loaded.
If you use AMFLiteDetectionFilter the device detection can't detect the screen size of mobile device, so the only think is to use the 'width' parameter as query string.
Type Image supported
AMFImageRendering module supports jpg, png, gif and animated gif. Also the module supports transparency.
Configuration
In the httpd.conf of Apache after the configuration of AMFWURFLFilter and AMFWURFLFIlterMemcached, it’s need to configure where the original images are store and the directory where resized images will be saved. This is the directive:
PerlSetEnv ResizeImageDirectory /home/AMF_home/img_resized
SetHandler modperl
PerlOutputFilterHandler Apache2::AMFImageRendering
with this example we say to AMFImageRendering that the original images are stored in “/img” and the image resized will be stored in “/home/AMF_home/img_resized”.
Note: the directory defined in ResizeImageDirectory must be writeable, and the original image is recommended be in high resolution for best quality results.
By default the images that have a width less than device screen size are not resized, if you want to force it:
PerlSetEnv ResizeSmallImage true
How to use
There three option to manage the images by your code:
The image is resized to the width of the screen:
The image is resized in proportion to the width of the screen for example 50%:
The image is forced to resize for some reason:
For change the name of parameter “width” and “dim” in httpd.conf must be setted:
PerlSetEnv ImageParamWidth PerlSetEnv ImageParamPerc
In the next picture show some examples:
File:ImageRenderingExample.jpg
To test AMFImageRendering:
http://fiftyone.apachemobilefilter.org/imageRendering.php
or
http://fiftyone.apachemobilefilter.org/imageRendering_anim.php
Tutorial