ResizeImage
CFile::ResizeImage( array File, array Size, resizeType = BX_RESIZE_IMAGE_PROPORTIONAL )
The method is the wrapper of ResizeImageFile. Changes sizes of image file. Static method.
Parameters
Parameter | Description |
---|---|
File | file array |
Size | Array of type array("width" => $width, "height" => $height)); both keys are required. |
resizeType | type of resizing:
|
Example
Creating thumbnail images "on the go":
$renderImage = CFile::ResizeImageGet($arResult["DETAIL_PICTURE"], Array("width" => $newWidth, "height" => $newHeight)); echo CFile::ShowImage($renderImage['src'], $newWidth, $newHeight, "border=0", "", true);
Resizing and saving of images:
// check file size and type. $checkfile = CFile::CheckFile($arFile,400000,'image/','gif,png,jpeg,jpg'); if(strlen($checkfile) > 0) { $strError .= $arFile['name'].': '.$strError.'<br>'; } else { // resize image CFile::ResizeImage( &$arFile, // path to image. Compressed file will be placed here as well. array( "width" => $newWidth, // new width "height" => $newHeight // new height ), BX_RESIZE_IMAGE_EXACT // resizing method. Cropping a rectangle image disregarding the size ratio. ); // save the cropped image. $fileId = CFile::SaveFile($arFile, $IBlockType); }
© «Bitrix24», 2001-2024