<?

function getWithOutPath($filename) {
return end(explode('/', $filename));
}

function get_size($size){
if ($size < 1024) $size = $size . ' Bt';
if ($size > 1024 and $size < 1048576) $size = round($size / 1024, 1) . ' Kb';
if ($size >= 1048576) $size = round(($size / 1024) / 1024, 1) . ' Mb';
return $size;
}

function img_copyright($img)
{
$copy_path = $_SERVER['DOCUMENT_ROOT'] . '/assets/public/copy.png';
if (isset($copy_path) && $copy_path != null && $copy = @imagecreatefromstring(file_get_contents($copy_path)))
{

$img_x = imagesx($img);
$img_y = imagesy($img);

$copy_x = imagesx($copy);
$copy_y = imagesy($copy);

$w = intval(min($img_x / 2.5, $copy_x, 128));
$h = intval(min($img_y / 2.5, $copy_y, 64));

$x_ratio = $w / $copy_x; 
$y_ratio = $h / $copy_y; 

if (($copy_x <= $w) && ($img_y <= $h))
{
	$dstW = $copy_x;
	$dstH = $copy_y;
} 
elseif (($x_ratio * $copy_y) < $h)
{ 
	$dstH = ceil($x_ratio * $copy_y);
	$dstW = $w;
}
else
{
	$dstW = ceil($y_ratio * $copy_x);
	$dstH = $h;
}
imagecopyresampled($img, $copy, $img_x - $dstW, $img_y - $dstH, 0, 0, $dstW, $dstH, $copy_x, $copy_y);

}

return $img;
}
function copy_img($img)
{
$copy_path = $_SERVER['DOCUMENT_ROOT'] . '/assets/public/copy.png';
if (isset($copy_path) && $copy_path != null && $copy = @imagecreatefromstring(file_get_contents($copy_path)))
{

$img_x = imagesx($img);
$img_y = imagesy($img);

$copy_x = imagesx($copy);
$copy_y = imagesy($copy);

$w = intval(min($img_x / 2.5, $copy_x, 128));
$h = intval(min($img_y / 2.5, $copy_y, 64));

$x_ratio = $w / $copy_x; 
$y_ratio = $h / $copy_y; 

if (($copy_x <= $w) && ($img_y <= $h))
{
	$dstW = $copy_x;
	$dstH = $copy_y;
} 
elseif (($x_ratio * $copy_y) < $h)
{ 
	$dstH = ceil($x_ratio * $copy_y);
	$dstW = $w;
}
else
{
	$dstW = ceil($y_ratio * $copy_x);
	$dstH = $h;
}
imagecopyresampled($img, $copy, $img_x - $dstW, $img_y - $dstH, 0, 0, $dstW, $dstH, $copy_x, $copy_y);

}

return $img;
}