AMFImageRendering

[article] [edit page] [discussion] [history]

From AMF Wiki

Contents

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:

AMFImageRendering.jpg

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,AMFWURFLFilterMemcached,AMFDetectRightFilter or AMFDetectRightFilterMemcached 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
<Location /img/*>
    SetHandler modperl
    PerlOutputFilterHandler Apache2::AMFImageRendering
</Location>

with this example we say to AMFImageRendering that the original images are stored in “<docroot>/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:

<img src=”/img/image.png”>

The image is resized in proportion to the width of the screen for example 50%:

<img src=”/img/image.png?dim=50”>

The image is forced to resize for some reason:

<img src=”/img/image.png?width=50>

For change the name of parameter “width” and “dim” in httpd.conf must be setted:

PerlSetEnv ImageParamWidth <new name of param>
PerlSetEnv ImageParamPerc <new name of param>

In the next picture show some examples:

ImageRenderingExample.jpg

To test AMFImageRendering:

http://w.apachemobilefilter.org/imageRendering.php

http://fiftyone.apachemobilefilter.org/imageRendering.php

or

http://w.apachemobilefilter.org/imageRendering_anim.php

http://fiftyone.apachemobilefilter.org/imageRendering_anim.php

Configuration AMF+ filter
AMF and mod_rewrite
Personal tools