Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> miniatury obrazków
Superhero
post 23.06.2005, 00:05:08
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 27.07.2004

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


chciałbym zrobić coś takiego, że uploaduje jakieś zdjęcie a strona w php 'robi' jego miniaturę, zapisuje ją a pierwotne zdjęcie usuwa, żeby nie zajmowało miejsca. czy jest to mozliwe?
Go to the top of the page
+Quote Post
vala
post 23.06.2005, 07:23:58
Post #2





Grupa: Zarejestrowani
Postów: 123
Pomógł: 0
Dołączył: 12.01.2005

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


mozliwe
poszukaj sobie tu odpowiedniej klasy : http://www.phpclasses.org/


--------------------
Warsztat: Easy PHP 1.7:Apache 1.3.27|PHP 4.3.3|PHPMYADMIn 2.5.3|MYSQL 4.0.15
Go to the top of the page
+Quote Post
gu35t
post 23.06.2005, 07:24:11
Post #3





Grupa: Zarejestrowani
Postów: 57
Pomógł: 0
Dołączył: 15.05.2005

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


tak. tu masz 2 skrypty.tylko sobie je dostosuj.
  1. <?
  2. function resize($im_file_name){
  3. $image_attribs = getimagesize($im_file_name); 
  4. $im_old = imageCreateFromJpeg($im_file_name);
  5. $th_max_width = 120;
  6. $th_max_height = 120; 
  7. if($image_attribs[0]>=$image_attribs[1]){
  8.  @$ratio = ($width >= $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1]; 
  9.  }
  10.  else{
  11. @$ratio = ($width < $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];
  12. }
  13. $th_width = $image_attribs[0] * $ratio;
  14. $th_height = $image_attribs[1] * $ratio;
  15. $im_new = imagecreatetruecolor($th_width,$th_height);
  16. $th_file_name = strrchr($im_file_name, &#092;"/\");
  17. $th_file_name = substr($im_file_name, 0 , strlen($im_file_name)-4) . '-thumb.jpg';
  18. imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);
  19. imageJpeg($im_new, $th_file_name ,80);
  20. }
  21. ?>


  1. <?
  2. $filejpg= './images/' . $_POST['dzial'] . '/' . date(&#092;"mdYHis\") . '.jpg';
  3. if(move_uploaded_file($_FILES['plik']['tmp_name'], $filejpg)){
  4. $f = fopen($filetext, &#092;"w+\");
  5. fputs($f, htmlspecialchars($_POST['cena']) . &#092;"n\");
  6. fputs($f, date(&#092;"mdYHis\"));
  7. fclose($f);
  8. resize($filejpg);
  9. print &#092;"zaladowano\";
  10.  
  11. }
  12. ?>


--------------------
env: Linux Slackware 10.1 [Kernel 2.6.5], PHP 4.3.9, Apache 1.3.33.
Go to the top of the page
+Quote Post
Superhero
post 23.06.2005, 11:35:46
Post #4





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 27.07.2004

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


Cytat(gu35t @ 2005-06-23 06:24:11)
tak. tu masz 2 skrypty.tylko sobie je dostosuj.

jeszcze tylko poprosze o wyjasnienie co robi pierwszy skypt a co drugi, w jakiej kolejnosci je uruchamiac i czy moga byc uruchamiane jeden po prugim.
Go to the top of the page
+Quote Post
vala
post 23.06.2005, 11:45:18
Post #5





Grupa: Zarejestrowani
Postów: 123
Pomógł: 0
Dołączył: 12.01.2005

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


2 skrypt to uploader
najpierw chciales wrzucac czyli upload a potem przycinac?

1 skrypt to przycinanie
definiujesz sobie
$th_max_width = 120;
$th_max_height = 120;

a nastepnie odpalasz go zaraz po uploadowaniu podajac jako parametr nazwe pliku


--------------------
Warsztat: Easy PHP 1.7:Apache 1.3.27|PHP 4.3.3|PHPMYADMIn 2.5.3|MYSQL 4.0.15
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: 31.07.2025 - 10:39