Kohana PHP has an image library that provides tools to manipulate an image and then save it to a desired location. DynamicImage is designed to deliver an existing image stored on the server to the client at any size, using one of three standard formats. The resulting image is not effecting the source, this library dynamically alters the image and delivers a new modified copy - the source remains untouched.
This library is designed to plug into Kohana PHP as a module, but you could use the library independently without the integrated controller.
KDynamicImage UseUsing clean URLs (recommended)To access images with KDynamicImage using URL's without GET arguments, use the following syntax to load an image without modification :
To augment the resource, insert a string formatted correctly between the file name and extention, separated by '.' so the full path still looks valid with a proper extension.
Note : The extension must be correct to the image resource, not the format you wish to receive the file in.
w100px output width in pixels, in this case 100px h140px output height in pixels, in this case 140px mrwidth maintain ratio based on width setting, replace 'width' with 'height' for reverse fpng output the file as a png, replace 'png' with 'jpg' or 'gif' for JPEG and GIF formats respectively mt1 maintain existing transparency. Omit this argument to not maintain transparency cr1 Crop ratio for the image width / height. A standard widescreen image has a crop ratio of 1.778 ( 16:9 ), where the width is 1.778 times the height. To use decimal values, ammend the decimal point with an underscore. bkF2C14F background colour for transparent images in HEX (without #) defaults to FFFFFF optional To use this within the URL, use the following syntax :
Using clean URLs can help with local caching within the web browser and ISPs. KDynamicImage can be processor intensive if you are serving a lot of images to a lot of clients simultaneously. Using clean URLs will help force browsers to cache the resource.
Using dynamic GET variablesTo access images with KDynamicImage using the GET method, use the following syntax to load an image without modification :
Using the built in controller you can add additional arguments to the GET request to augment the original resource :
width output width in pixels (don't add px to value) optional, required if mr='width' height output height in pixels (don't add px to value) optional, required if mr='height' mr maintain ratio, valid values or 'width' or 'height' optional, requires either a width or height format output image format ('gif', 'jpg' or 'png'), defaults to input format optional mt keep gif/png transparency if set to 'true' defaults to FALSE optional bk background colour for transparent images in HEX (without #) defaults to FFFFFF optional cr Crop ratio for the image width / height. A standard widescreen image has a crop ratio of 1.778 ( 16:9 ), where the width is 1.778 times the height. Although the module is designed to work with Kohana PHP, the library itself could exist independently of Kohana. More details of this will be available on Google Code where you can download the latest release or checkout the latest revisions from SVN.
This library requires GD 2.0 for PHP to be installed on your web server