Important notice: the development of WideImage 1.0 branch is discontinued.
Please visit
http://wideimage.sourceforge.net for the new version of library and documentation.
This web site will remain accessible to serve as documentation for the old versions of the library.
For help on migration, please refer
to the
migration
guide.
wiImage::resize()
See also:
List of operations
Signature
wiImage::resize($width = null, $height = null, $fit = 'inside')
Parameters
- $width (int, string): new width. Can be an integer or a percent string. If not specified, value of $height is used.
- $height (int, string): new height. Can be an integer or a percent string. If not specified, value of $width is used.
- $fit (string): fit method. Valid values are: inside, fill, outside.
- result (wiTrueColorImage): resized image
Description
This method will resize an image to the specified dimensions using the specified fit-method.
Fit methods:
- inside: the image will fit inside the new dimensions while maintaining the aspect ratio.
- fill: the image will completely fit inside the new dimensions.
- outside: the image will fit outside of the new dimensions, which means that it will be resized to completely fill the specified rectangle, while still maintaining aspect ratio.
Notes
- images are resized with imagecopyresampled(), unless they're transparent. Transparent images are resized with imagecopyresized(), which maintains the transparency information, but reduces the quality of the resized image.
Examples
$img = wiImage::load('/path/to/an/image.png');
// resize to 50% of the size, maintain aspect ratio
$res = $img->resize('50%');
// same as above
$res = $img->resize(null, '50%');
// resize and save
$img->resize(100, '30%', 'fill')->saveToFile('resized.jpg');
CategoryDocApi
There are no comments on this page. [Add comment]