View file Dasty_Social/modules/obmen/inc/file/png.php

File size: 1.31Kb
<?
if (is_file(H."sys/obmen/screens/128/$file_id[id].$ras"))
{
	echo "<center><img style='border: 2px solid white; box-shadow: 0px 2px 2px #dedede; width:300px;' src='/sys/obmen/screens/128/$file_id[id].$ras' alt='Скрин...' /></center>";
}
elseif (function_exists('imagecreatefromstring'))
{
	$imgc = imagecreatefromstring(file_get_contents($file));
	$img_x = imagesx($imgc);
	$img_y = imagesy($imgc);
	
	if ($img_x == $img_y)
	{
		$dstW = 128; // ширина
		$dstH = 128; // высота 
	}
	elseif ($img_x > $img_y)
	{
		$prop = $img_x / $img_y;
		$dstW = 128;
		$dstH = ceil($dstW / $prop);
	}
	else
	{
		$prop = $img_y/$img_x;
		$dstH = 128;
		$dstW = ceil($dstH/$prop);
	}

	$screen = imagecreatetruecolor($dstW, $dstH);
	$black = imagecolorallocate ($screen, 0, 0, 0);
	imagecolortransparent($screen,$black);
	imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
	imagedestroy($imgc);
	$screen = img_copyright($screen); // наложение копирайта
	imagepng($screen,H."sys/obmen/screens/128/$file_id[id].$ras");
	imagedestroy($screen);
	echo "<img src='/sys/obmen/screens/128/$file_id[id].$ras' alt='Скрин...' /><br />\n";
}

if ($file_id['opis'] != NULL){
echo '</div>';
echo '<div class="menu">';
echo output_text($file_id['opis']);
}

?>