You are here

public static function FileCommited::resizeImageNative in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

1 call to FileCommited::resizeImageNative()
FileCommited::resizeImage in vendor/edsdk/file-uploader-server-php/src/lib/file/FileCommited.php

File

vendor/edsdk/file-uploader-server-php/src/lib/file/FileCommited.php, line 239

Class

FileCommited

Namespace

EdSDK\FileUploaderServer\lib\file

Code

public static function resizeImageNative($image, $scaleW, $scaleH, $fitMode) {
  $newW = $scaleW;
  $newH = $scaleH;
  if ($fitMode == FileCommited::FIT_TO_WIDTH) {
    $newH = round($newW * $scaleH / $scaleW);
  }
  else {
    if ($fitMode == FileCommited::FIT_TO_HEIGHT) {
      $newW = round($newH * $scaleW / $scaleH);
    }
  }
  $newImage = imagecreatetruecolor($newW, $newH);
  imagealphablending($newImage, false);
  imagesavealpha($newImage, true);
  imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newW, $newH, imagesx($image), imagesy($image));
  return $newImage;
}