Mikijs Posted January 5, 2008 Report Share Posted January 5, 2008 (edited) Ok Kods gatavs.. Pārbaudei Attēls: http://www.teiksmina.lv/start.PNG Thumbs: www.teiksmina.lv/tumbs.php?pik4ers=start.PNG <?php if ($pik4ers) { thumb($pik4ers, 100, 100); } else{ echo "Soo.. where the bilde? :D"; } function thumb($img, $w, $h, $fill = true) { if (!extension_loaded('gd') && !extension_loaded('gd2')) { trigger_error("Iesledziet GD/gd2.", E_USER_WARNING); return false; } $imgInfo = getimagesize($img); switch ($imgInfo[2]) { case 1: $im = imagecreatefromgif($img); break; case 2: $im = imagecreatefromjpeg($img); break; case 3: $im = imagecreatefrompng($img); break; default: trigger_error('Nepareizs tips.', E_USER_WARNING); break; } if ($imgInfo[0] <= $w && $imgInfo[1] <= $h && !$fill) { $nHeight = $imgInfo[1]; $nWidth = $imgInfo[0]; }else{ if ($w/$imgInfo[0] < $h/$imgInfo[1]) { $nWidth = $w; $nHeight = $imgInfo[1]*($w/$imgInfo[0]); }else{ $nWidth = $imgInfo[0]*($h/$imgInfo[1]); $nHeight = $h; } } $nWidth = round($nWidth); $nHeight = round($nHeight); $newImg = imagecreatetruecolor($nWidth, $nHeight); imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]); header("Content-type: ". $imgInfo['mime']); switch ($imgInfo[2]) { case 1: imagegif($newImg); break; case 2: imagejpeg($newImg); break; case 3: imagepng($newImg); break; default: trigger_error('Neiespejami.', E_USER_WARNING); break; } imagedestroy($newImg); } ?> Edited January 5, 2008 by Mikijs Link to comment Share on other sites More sharing options...
wormy Posted January 5, 2008 Author Report Share Posted January 5, 2008 TnX man U da BEST :) Link to comment Share on other sites More sharing options...
Mikijs Posted January 5, 2008 Report Share Posted January 5, 2008 Aww.. :D 2.50.. no jums :) xDDD :D npk.. Link to comment Share on other sites More sharing options...
marcis Posted January 5, 2008 Report Share Posted January 5, 2008 Patiesībā risinājums nav no labakajiem, vieglāk/ātrāk/ērtāk būtu thrumbu pieglabāt serverī jau pie upload! Mikijam ieteiktu labāk neizmantot globaļus, tb $_GET['pik4ers'] nevis $pik4ers. Šeit jau itkā pofig bet dzīvē tas mēdz sagādāt ne mazums problemas, vnk nav labs stils. Link to comment Share on other sites More sharing options...
Mikijs Posted January 6, 2008 Report Share Posted January 6, 2008 zinu, bet taka wormy pazistams utt.. tad es vinjam pec tam to skriptu partaisiju :) pats sapratu .. bet paldies :) Link to comment Share on other sites More sharing options...
Recommended Posts