Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> resize jpg do stalej wysokosci
spandor
post
Post #1





Grupa: Zarejestrowani
Postów: 99
Pomógł: 0
Dołączył: 2.03.2004

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


Witam

Mam taki problem, nie daje sobie rady ze zmiana tego skryptu aby zmiejszal fotke do zgory zadanej wysokosci. Ze podaje wysokosc 100 pix a on do tej wysokosci dobiera szerokosc.

pozd

  1. <?php
  2. function Resize($strName, $strNewName, $intMax) {
  3. // Wczytanie obrazka z pliku $strName
  4. $resImg = imagecreatefromjpeg($strName);
  5.  
  6. // Rozmiary obrazka
  7. $intWidth = imagesx($resImg); //szerokość
  8. $intHeight = imagesy($resImg); //wysokość
  9.  
  10. // Proporcje długości do szerokońci
  11. $floRatio = $intWidth / $intHeight;
  12.  
  13. // Wyliczenie skali do zmniejszenia
  14. if ($floRatio >= 1) {
  15. //poziome
  16. if ($intHeight < 800 && $intMax == 800) {
  17. $intMax = $intHeight;
  18. }
  19. $intNewHeight = $intMax;
  20. $intNewWidth = ($intMax / $floRatio);
  21. } else {
  22. //pionowe
  23. if ($intWidth < 600 && $intMax == 800) {
  24. $intMax = $intWidth;
  25. }
  26. $intNewWidth = $intMax;
  27. $intNewHeight = ($intMax * $floRatio);
  28. }
  29.  
  30. // Utworzenie "nowego" obrazka (pola roboczego) o wyliczonym rozmiarze
  31. $resTempImg = imagecreatetruecolor($intNewWidth, $intNewHeight);
  32.  
  33. // Przekopoiwanie wraz ze skalowaniem obrazka zródłowego na docelowy
  34. imagecopyresampled($resTempImg, $resImg, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight );
  35.  
  36. // Zapis "nowego" obrazka do pliku podanym jako $strNewName
  37. imagejpeg($resTempImg, $strNewName);
  38. }
  39. ?>


Ten post edytował spandor 14.08.2007, 04:37: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: 23.12.2025 - 15:40