NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/public_html/administrator/components/com_sppagebuilder/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/public_html/administrator/components/com_sppagebuilder/helpers/image.php
<?php
/**
* @package SP Page Builder
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2022 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
//no direct accees
defined ('_JEXEC') or die ('Restricted access');

class SppagebuilderHelperImage {

	public $height;
	public $width;
	private $src;

	public function __construct($src = '') {
		$this->src = $src;
		list($this->width, $this->height) = getimagesize($src);
	}

	public function getDimension() {
		return [$this->width, $this->height];
	}

	/**
	 * Create thumb image with specifice height and width and with their ratio
	 */
	public function createThumb($size = array(), $destination = '', $base_name = '', $ext = '', $quality = 100 ) {

		$img = $this->createImageFromType($ext);

		if(count((array) $size) && $img != null ) {
			$targetWidth = $size[0];
			$targetHeight = $size[1];

			$ratio_thumb = $targetWidth/$targetHeight;
			$ratio_original = $this->width/$this->height;

			if ($ratio_original >= $ratio_thumb) {
				$height = $this->height;
				$width = ceil(($height*$targetWidth)/$targetHeight);
				$x = ceil(($this->width-$width)/2);
				$y = 0;
			} else {
				$width = $this->width;
				$height = ceil(($width*$targetHeight)/$targetWidth);
				$y = ceil(($this->height-$height)/2);
				$x = 0;
			}

			$new = imagecreatetruecolor($targetWidth, $targetHeight);

			if($ext == "gif" or $ext == "png") {
				imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
				imagealphablending($new, false);
				imagesavealpha($new, true);
			}

			imagecopyresampled($new, $img, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);

			$dest = $destination . '/' . $base_name . '.' . $ext;

			$this->cloneImage($ext, $new, $dest, $quality);

			return true;
		}

		return false;
	}
 
	/**
	 * Clone Image from original to destination source based on extension
	 */
	private function cloneImage($ext, $new, $dest, $quality){
		switch($ext) {
			case 'bmp': imagewbmp($new, $dest); break;
			case 'gif': imagegif($new, $dest); break;
			case 'jpg': imagejpeg($new, $dest, $quality); break;
			case 'jpeg': imagejpeg($new, $dest, $quality); break;
			case 'png': imagepng($new, $dest, floor($quality/11)); break;
		}
	}

	/**
	 * Create Image from their specifice extension
	 */
	private function createImageFromType($ext) {
		switch($ext) {
			case 'bmp': $img = imagecreatefromwbmp($this->src); break;
			case 'gif': $img = imagecreatefromgif($this->src); break;
			case 'jpg': $img = imagecreatefromjpeg($this->src); break;
			case 'jpeg': $img = imagecreatefromjpeg($this->src); break;
			case 'png': $img = imagecreatefrompng($this->src); break;
		}
		return $img;
	}
}

NexusLeads