/** * Resizes image to desired width and height, returns true on success. * * @param string $sSrc Source of image file * @param string $sTarget Target to write resized image file * @param mixed $iDesiredWidth Width of resized image * @param mixed $iDesiredHeight Height of resized image * * @return bool */ public function resizeImage($sSrc, $sTarget, $iDesiredWidth, $iDesiredHeight) { // use this GD Version if (($iUseGDVersion = getGdVersion()) && function_exists('imagecreate') && file_exists($sSrc) && ($aImageInfo = @getimagesize($sSrc))) { $myConfig = $this->getConfig(); list($iWidth, $iHeight) = calcImageSize($iDesiredWidth, $iDesiredHeight, $aImageInfo[0], $aImageInfo[1]); return $this->_resize($aImageInfo, $sSrc, null, $sTarget, $iWidth, $iHeight, $iUseGDVersion, $myConfig->getConfigParam('blDisableTouch'), $myConfig->getConfigParam('sDefaultImageQuality')); } return false; }
/** * Checks if preferred image dimensions size matches defined in config; * in case it matches - copies original image to new location, returns * copying state - TRUE/FALSe else - returns array with new dimensions * array( $iNewWidth, $iNewHeight ); * * @param string $sSrc image source file name * @param string $sTarget target location * @param int $iWidth preferred width * @param int $iHeight preferred height * @param int $iOrigWidth original width * @param int $iOrigHeigth preferred height * * @return mixed */ function checkSizeAndCopy($sSrc, $sTarget, $iWidth, $iHeight, $iOrigWidth, $iOrigHeigth) { list($iNewWidth, $iNewHeight) = calcImageSize($iWidth, $iHeight, $iOrigWidth, $iOrigHeigth); if ($iNewWidth == $iOrigWidth && $iNewHeight == $iOrigHeigth) { return copy($sSrc, $sTarget); } else { return array($iNewWidth, $iNewHeight); } }