Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] thumbnail obrazka - problem
bastek8989
post
Post #1





Grupa: Zarejestrowani
Postów: 205
Pomógł: 1
Dołączył: 11.09.2006

Ostrzeżenie: (0%)
-----


witam

Mam pewien problem odnosnie thumbnail obrazka:
polega on na tym, ze ustawiam rozmiar 99x59 a thumb robi sie na szerokosc 59 lecz zeby zachowac proporcje wystaje znacznie poza okreslona wysokosc 59 i w ten sposob strona mi sie moze rozjechac.

i tu pytanie:

Da sie to jakos obejsc te proporcje?
Zeby skrypt bral pod uwage ze ma do dyspozycji 59x99 i wg tego ustalal proporcjonalny obrazek?


prosze o pomoc
pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
eS...
post
Post #2





Grupa: Zarejestrowani
Postów: 367
Pomógł: 2
Dołączył: 4.03.2003
Skąd: C:/Windows/Temp

Ostrzeżenie: (0%)
-----


  1. <?php
  2. function scale($img,$maxwidth,$maxheight) { 
  3. $imginfo = getimagesize($img); 
  4. $imgwidth = $imginfo[0]; 
  5. $imgheight = $imginfo[1]; 
  6. if ($imgwidth > $maxwidth) { 
  7. $ration = $maxwidth/$imgwidth; 
  8. $newwidth = round($imgwidth*$ration); 
  9. $newheight = round($imgheight*$ration); 
  10. if ($newheight > $maxheight) { 
  11. $ration = $maxheight/$newheight; 
  12. $newwidth = round($newwidth*$ration); 
  13. $newheight = round($newheight*$ration); 
  14. return array("image" => $img, "width" => $newwidth, "height" => $newheight); 
  15. } else { 
  16. return array("image" => $img, "width" => $newwidth, "height" => $newheight); 
  17. } 
  18. } else if ($imgheight > $maxheight) { 
  19. $ration = $maxheight/$imgheight; 
  20. $newwidth = round($imgwidth*$ration); 
  21. $newheight = round($imgheight*$ration); 
  22. if ($newwidth > $maxwidth) { 
  23. $ration = $maxwidth/$newwidth; 
  24. $newwidth = round($newwidth*$ration); 
  25. $newheight = round($newheight*$ration); 
  26. return array("image" => $img, "width" => $newwidth, "height" => $newheight); 
  27. } else { 
  28. return array("image" => $img, "width" => $newwidth, "height" => $newheight); 
  29. } 
  30. } else { 
  31. return array("image" => $img, "width" => $imgwidth, "height" => $imgheight); 
  32. } 
  33. }
  34. ?>

$maxwidth i $maxheight i po sprawie

Ten post edytował eS... 12.01.2007, 16:51:00
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 05:45