Documentation

ResizeImageFile

CFile::ResizeImageFile(
 $sourceFile,
 &$destinationFile,
 $arSize,
 $resizeType = BX_RESIZE_IMAGE_PROPORTIONAL,
 $arWaterMark = array(),
 $jpgQuality=false,
 $arFilters=false
)

The method modifies image file size. If the original file has .BMP extension, the destination file will be converted to .JPEG format and the modified name will be returned into intodestinationFile. Static method.

Parameters

Parameter Description Available fr om version
sourceFile Path original source file
destinationFile Path to destination file, resulting fr om the processing. If the source file has .BMP format, the file will be converted to .JPEG format and the modified name will be returned into intodestinationFile.
Size Array of type array("width" => $width, "height" => $height)); both keys are required.
resizeType type of resizing:
  • BX_RESIZE_IMAGE_EXACT - resizes into rectangle $arSize without saving the proportions;
  • BX_RESIZE_IMAGE_PROPORTIONAL - resizes with retaining of proportions, the size is limited by $arSize;
  • BX_RESIZE_IMAGE_PROPORTIONAL_ALT - resizes with retaining of proportions, the size is limited by $arSize. Improved processing of vertical images.
arWaterMark array with watermark parameters, the keys are the following:
  • text - watermark text
  • font - path TTF font (TTF/UTF-8)
  • type - text or image
  • min_size_picture - minimum image width
  • color - "RRGGBB" color
  • alpha_level - opacity from 0 to 100, wh ere 0 = transparent, 100 = opaque. (Applicable only for author mark as an image.)
  • size - size. big; medium; small; real. A coefficient can be specified via the 'coefficient' parameter for arbitrary resizing; the 'real' parameter is applicable only for images ('type'=>'image')
  • position - specifies the position of the watermark on the image in two notes:
    • "{m|b}{c|r}", wh ere m - center in vertical direction, b - bottom, c - center in horizontal direction, r - right edge.
    • topleft; topcenter; topright; centerleft; center; centerright; bottomleft; bottomcenter; bottomright.
jpgQuality Degree of JPG-compression. Optional parameter. By default - false, which equals to 95% image quality. If the full quality is required, pass the "100" in the parameter.
Filters Array of filter parameters. Optional parameter. By default - false.

Examples of use



© «Bitrix24», 2001-2022
Up