Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] thumbnail obrazka - problem
bastek8989
post 12.01.2007, 15:17:37
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


--------------------
Web-Anatomy.com - tworzenie serwisów internetowych oraz stron www z okolic Bielska-Białej. Zapraszam.
Go to the top of the page
+Quote Post
maryaan
post 12.01.2007, 15:36:31
Post #2





Grupa: Zarejestrowani
Postów: 380
Pomógł: 2
Dołączył: 5.01.2007

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


a ten... widzisz tu gdizesz wrozke? moze bys wkleil ten skrypt ktory ma robic miniature? blinksmiley.gif


--------------------
Wybierasz się do Zakopanego? Odwiedź Willę Pod Górami. Następnym razem na pewno do niej wrócisz :)
Go to the top of the page
+Quote Post
bastek8989
post 12.01.2007, 16:37:19
Post #3





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

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


pytam jak a nie szukam bledu - sam sobie zastosuje sposob

Ten post edytował bastek8989 12.01.2007, 16:37:32


--------------------
Web-Anatomy.com - tworzenie serwisów internetowych oraz stron www z okolic Bielska-Białej. Zapraszam.
Go to the top of the page
+Quote Post
eS...
post 12.01.2007, 16:49:13
Post #4





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
bastek8989
post 12.01.2007, 19:46:27
Post #5





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

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


to co widze nierozwiazuje problemu (z tego co widze - nie sprawdzalem)

sam sobie zrobilem dzialanie, mzoe komus sie przyda..


$newwidth = round($newwidth*$ration);
$newheight = round($newheight*$ration);

== u mnie jest

$new_x = $image_x*$ratio_x;
$new_y = $image_y*$ratio_y;

to nie zalatwia sprawy

wystarczy:

$h = $new_y - $max_h;
$new_x = $new_x - $h;
$new_y = $new_y - $h;

tego mi brakowalo - teraz juz nie mam problemu z uciekaniem za wskazany H

Ten post edytował bastek8989 12.01.2007, 19:47:55


--------------------
Web-Anatomy.com - tworzenie serwisów internetowych oraz stron www z okolic Bielska-Białej. Zapraszam.
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 20.07.2025 - 02:50