Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Przycinanie obrazka
motor
post
Post #1





Grupa: Zarejestrowani
Postów: 211
Pomógł: 0
Dołączył: 15.12.2005

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


Witam
mam taki dylemat chcę przyciąć obrazki jpg z góry i z dołu o daną wartość zawsze tą samą .

szukam najlepiej gotowego skryptu
na forum znalazłem coś takiego

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


Ale coś mi nie działa nie wiem dlaczego ?
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 - 22:27