Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> biblioteka GD, zapisać na dysk, wygenerowaną miniaturę
1maciek
post
Post #1





Grupa: Zarejestrowani
Postów: 75
Pomógł: 0
Dołączył: 12.10.2004

Ostrzeżenie: (10%)
X----


witam, tak jak w temacie, generuje pomniejszone zdjecie i chcialbym zapisac je (to pomniejszone) na dysk, czy jest to mozliwe? a jesli tak to w jaki sposob
pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
eai
post
Post #2





Grupa: Zarejestrowani
Postów: 367
Pomógł: 10
Dołączył: 20.05.2005

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


Jakbys otworzyl jeden z linkow jojo to byś wiedział że:


  1. <?php
  2.  
  3. function miniature($pict, $dest_pict){
  4.  
  5.  $handle = @imagecreatefromjpeg($pict);
  6.  
  7.  $x=imagesx($handle);
  8.  $y=imagesy($handle);
  9.  
  10.  if($x > $y){  
  11.  $max = $x;  
  12.  $min = $y;  
  13.  }  
  14.  if($x <= $y){  
  15.  $max = $y;  
  16.  $min = $x;  
  17.  }  
  18.  
  19. //$size_in_pixel : Size max of the label in pixel. The size of the picture being
  20. //proportional to the original, this value define maximum size
  21. //of largest side with dimensions of the picture. Sorry for my english !
  22.  
  23. //Here $size_in_pixel = 100 for a thumbnail.
  24.  $size_in_pixel = '100';
  25.  
  26.  $rate = $max/$size_in_pixel;
  27.  $final_x = $x/$rate;
  28.  $final_y = $y/$rate;
  29.  
  30.  if($final_x > $x) {
  31.  $final_x = $x;
  32.  $final_y = $y;
  33.  }
  34.  
  35.  $final_x = ceil($final_x);
  36.  $final_y = ceil($final_y);
  37.  
  38.  $black_picture = imageCreatetruecolor($final_x,$final_y);
  39.  imagefill($black_picture,0,0,imagecolorallocate($black_picture, 255, 255, 255));
  40.  imagecopyresampled($black_picture, $handle, 0, 0, 0, 0,$final_x, $final_y, $x, $y);
  41.  
  42.  if(!@imagejpeg($black_picture,$dest_pict.'/mini_'.$pict, $size_in_pixel))
  43.  imagestring($black_picture, 1, $final_x-4, $final_y-8, ".", imagecolorallocate($black_picture,0,0,0));
  44.  
  45.  //The number is the quality of the result picture
  46.  imagejpeg($black_picture,'', '100');
  47.  imagedestroy($handle);
  48.  imagedestroy($black_picture);
  49.  }
  50.  
  51. $pict = "PICT7024.jpg";
  52. $dest_pict = "D:/Program Files/EasyPHP1-7/www/test";
  53. miniature($pict, $dest_pict);
  54.  
  55. ?>
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: 10.10.2025 - 09:25