Perforce Chronicle provides an image library that can perform select image manipulations, such as scaling, to be done on the server. Using the image library greatly assists theme developers, who can specify sizes for images to fit within the theme without having to restrict the sizes of images that users upload. This chapter is focused on module developers, providing an overview of how the image library works, and how to interact with and extend the image library.
While the image library can provide better image quality, or can help reduce bandwidth, it requires an additional PHP extension to be installed on the server. If necessary, ask your system administrator to install one of the following extensions:
Currently supported libraries include:
If you have more than one of the supported image libraries installed, Chronicle defaults to using ImageMagick, if available, then GD.
Chronicle provides the following transformations in each of the supplied drivers:
<?php $image->transform('crop', array(width, height, x, y));
widthspecifies the integer width in pixels of the cropped image.
heightspecifies the integer height in pixels of the cropped image.
xspecifies the integer starting pixel of the crop from the left side. 0 would begin the crop with the left-most pixel.
yspecifies the integer starting pixel of the crop from the top side. 0 would begin the crop with the top-most pixel.
<?php $image->transform('rotate', array(degrees));
degreesspecifies the floating point degrees to rotate the image by, in the clock-wise direction.
<?php $image->transform('scale', array(width, height));
widthspecifies the integer width in pixels of the scaled image.
heightspecifies the integer height in pixels of the scaled image.
|Maintaining Aspect Ratio|
If only the width, or the height, is specified, the image is scaled to match the specified size, and the unspecified size is computed to maintain the aspect ratio, or shape, of the image.
For example, if the original image is 1024x768 pixels, invoking