Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Miniaturki:)
wozniak
post
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

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


Witam, mam skrypcik do robienia miniaturek tylko z formularza ida 3 zdjecia i teraz mam pytanie musze powielic ten kod 3 razy i zmienic nazwe zmiennych czy moze jest jakis inny sposob?
Skrypt:
  1. <?php
  2. $pic = $_FILES['userfile']['tmp_name'];
  3.  
  4.  $jpegImg = imageCreateFromJPEG($pic);
  5.  
  6. unlink($pic);
  7.  
  8.  $imgsizex = imageSX($jpegImg);
  9.  $imgsizey = imageSY($jpegImg);
  10.  
  11. $jpegImg_small = imagecreatetruecolor(160, 160);
  12.  
  13. if ($imgsizex <> $imgsizey) {
  14.  
  15. if ($imgsizex > 160 OR $imgsizey > 160) {
  16.  
  17. if ($imgsizex < $imgsizey) {
  18.  
  19. $ax = $imgsizex / 160;
  20. $axs = (integer) $ax;
  21. $axr = 160 * $axs + ($imgsizex - 160 * $axs);
  22. $ayr = 160 * $axs + ($imgsizex - 160 * $axs);
  23.  
  24. } else {
  25.  
  26. $ay = $imgsizey / 160;
  27. $ays = (integer) $ay;
  28. $ayr = 160 * $ays + ($imgsizey - 160 * $ays);
  29. $axr = 160 * $ays + ($imgsizey - 160 * $ays);
  30.  
  31. }
  32.  
  33. $jpegImg_dst = imagecreatetruecolor($axr, $ayr);
  34. imagecopymerge($jpegImg_dst, $jpegImg, 0, 0, 0, 0, $axr, $ayr, 100);
  35. $imgsizex = $axr;
  36. $imgsizey = $ayr;
  37.  
  38. } else {
  39.  
  40. $jpegImg_dst = $jpegImg;
  41.  
  42. }
  43.  
  44. } else {
  45.  
  46. $jpegImg_dst = $jpegImg;
  47.  
  48. }
  49.  
  50. imagecopyresampled($jpegImg_small, $jpegImg_dst, 0, 0, 0, 0,
  51.  160, 160, $imgsizex, $imgsizey);
  52.  
  53. $resizedfilename = substr(ereg_replace("[^A-Za-z0-9]", "", 
  54. crypt(time())) .
  55.  ereg_replace("[^A-Za-z0-9]", "", crypt(time())) .
  56.  ereg_replace("[^A-Za-z0-9]", "", crypt(time())),
  57.  0, 8);
  58.  
  59.  $dirtosaveresized = getcwd()."/grafika/".$resizedfilename.".jpg";
  60.  
  61.  ImageJPEG($jpegImg_small, $dirtosaveresized, 65);
  62. ?>
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: 22.08.2025 - 15:34