include the Zebra_Image library
require 'path/to/Zebra_Image.php';
instantiate the class
$img = new Zebra_Image();
a source image
$img->source_path = 'path/to/source.ext';
path to where should the resulting image be saved
note that by simply setting a different extension to the file will
instruct the script to create an image of that particular type
$img->target_path = 'path/to/target.ext';
apply a "sharpen" filter to the resulting images
$img->sharpen_images = true;
resize the image to exactly 150x150 pixels, without altering aspect ratio, by using the CROP_CENTER method
$img->resize(150, 150, ZEBRA_IMAGE_CROP_CENTER);
public resize ( integer $width, integer $height, integer $method = ZEBRA_IMAGE_CROP_CENTER, hexadecimal $background_color = '#FFFFFF' ) : boolean | ||
$width | integer | The width to resize the image to. If set to 0, the width will be automatically adjusted, depending on the value of the height argument so that the image preserves its aspect ratio. If {@link preserve_aspect_ratio} is set to TRUE and both this and the height arguments are values greater than 0, the image will be resized to the exact required width and height and the aspect ratio will be preserved - (also see the description for the method argument below on how can this be done). If {@link preserve_aspect_ratio} is set to FALSE, the image will be resized to the required width and the aspect ratio will be ignored. If both width and height are set to 0, a copy of the source image will be created ({@link jpeg_quality} and {@link png_compression} will still apply). If either width or height are set to 0, the script will consider the value of the {@link preserve_aspect_ratio} to bet set to TRUE regardless of its actual value! @param integer $height The height to resize the image to. If set to 0, the height will be automatically adjusted, depending on the value of the width argument so that the image preserves its aspect ratio. If {@link preserve_aspect_ratio} is set to TRUE and both this and the width arguments are values greater than 0, the image will be resized to the exact required width and height and the aspect ratio will be preserved - (also see the description for the method argument below on how can this be done). If {@link preserve_aspect_ratio} is set to FALSE, the image will be resized to the required height and the aspect ratio will be ignored. If both width and height are set to 0, a copy of the source image will be created ({@link jpeg_quality} and {@link png_compression} will still apply). If either height or width are set to 0, the script will consider the value of the {@link preserve_aspect_ratio} to bet set to TRUE regardless of its actual value! @param int $method (Optional) Method to use when resizing images to exact width and height while preserving aspect ratio. If the {@link preserve_aspect_ratio} property is set to TRUE and both the width and height arguments are values greater than 0, the image will be resized to the exact given width and height and the aspect ratio will be preserved by using on of the following methods: - ZEBRA_IMAGE_BOXED - the image will be scalled so that it will fit in a box with the given width and height (both width/height will be smaller or equal to the required width/height) and then it will be centered both horizontally and vertically. The blank area will be filled with the color specified by the bgcolor argument. (the blank area will be filled only if the image is not transparent!) - ZEBRA_IMAGE_NOT_BOXED - the image will be scalled so that it could fit in a box with the given width and height but will not be enclosed in a box with given width and height. The new width/ height will be both smaller or equal to the required width/height - ZEBRA_IMAGE_CROP_TOPLEFT - ZEBRA_IMAGE_CROP_TOPCENTER - ZEBRA_IMAGE_CROP_TOPRIGHT - ZEBRA_IMAGE_CROP_MIDDLELEFT - ZEBRA_IMAGE_CROP_CENTER - ZEBRA_IMAGE_CROP_MIDDLERIGHT - ZEBRA_IMAGE_CROP_BOTTOMLEFT - ZEBRA_IMAGE_CROP_BOTTOMCENTER - ZEBRA_IMAGE_CROP_BOTTOMRIGHT For the methods involving crop, first the image is scaled so that both its sides are equal or greater than the respective sizes of the bounding box; next, a region of required width and height will be cropped from indicated region of the resulted image. Default is ZEBRA_IMAGE_CROP_CENTER @param hexadecimal $background_color (Optional) The hexadecimal color (like "#FFFFFF" or "#FFF") of the blank area. See the method argument. When set to -1 the script will preserve transparency for transparent GIF and PNG images. For non-transparent images the background will be white in this case. Default is #FFFFFF. @return boolean Returns TRUE on success or FALSE on error. If FALSE is returned, check the {@link error} property to see what went wrong |
$height | integer | |
$method | integer | |
$background_color | hexadecimal | |
return | boolean |