Kód: Vybrať všetko
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath2 = "kategorie/thumb/";
$rozmer = getimagesize($_FILES['Filedata']['tmp_name']);
if($rozmer[1] > $rozmer[0])
{
$pomer = $rozmer[1]/$rozmer[0];
if($_FILES['Filedata']['type']=="image/jpeg")
{
$povodny = imagecreatefromjpeg($tempFile);
$novy = imagecreatetruecolor(100/$pomer, 100);
imagecopyresampled ($novy, $povodny, 0, 0, 0, 0, 100/$pomer, 100, $rozmer[0], $rozmer[1]);
imagejpeg($novy,$targetPath2 . $_FILES['Filedata']['name'], 50);
imagedestroy($novy);
imagedestroy($povodny);
}
else
{
$povodny = imagecreatefrompng($tempFile);
$novy = imagecreatetruecolor(100/$pomer, 100);
imagecopyresampled ($novy, $povodny, 0, 0, 0, 0, 100/$pomer, 100, $rozmer[0], $rozmer[1]);
imagejpeg($novy,$targetPath2 . $_FILES['Filedata']['name'], 50);
imagedestroy($novy);
imagedestroy($povodny);
}
}
else
{
$pomer = $rozmer[0]/$rozmer[1];
if($_FILES['Filedata']['type']=="image/jpeg")
{
$povodny = imagecreatefromjpeg($tempFile);
$novy = imagecreatetruecolor(100, 100/$pomer);
imagecopyresampled ($novy, $povodny, 0, 0, 0, 0, 100, 100/$pomer, $rozmer[0], $rozmer[1]);
imagejpeg($novy,$targetPath2 . $_FILES['Filedata']['name'], 50);
imagedestroy($novy);
imagedestroy($povodny);
}
else
{
$povodny = imagecreatefrompng($tempFile);
$novy = imagecreatetruecolor(100, 100/$pomer);
imagecopyresampled ($novy, $povodny, 0, 0, 0, 0, 100, 100/$pomer, $rozmer[0], $rozmer[1]);
imagejpeg($novy,$targetPath2 . $_FILES['Filedata']['name'], 50);
imagedestroy($novy);
imagedestroy($povodny);
}
}