Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]function.imagecreatetruecolor
^(-.-)^
post
Post #1





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 4.09.2008

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


mam taki problem co sie dzieje na kazdym serwerze jako uzywam. Testowalem w darmowych serwerach kod php i za kazdym razem mi sie taki blad pokazuje.

Cytat
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/a8487159/public_html/resizejpeg.php on line 11


a kod php gdzie jest kod wyglada mniej wiecej taki
Kod
               8-list($width, $height) = getimagesize($file);
               9-$new_width = $sze;
               10-$new_height = $wys;
               11-$image_p = imagecreatetruecolor($new_width, $new_height);


czy ktos moze mi powiedziec o co chodzi z tym imagecreatetruecolor?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (znaczy czytalem cos na temat tego imagecreatetruecolor na stronie phpclasses i na stronie php.pl ale nadal nie jasne (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) wiecie jak to naprawic?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

to raz. A 2 jest to ze pozniej jak chcialbym zapisac obrazek na kompie to zamiast zapisac tego obrazka np w formacie .jpeg to mi sie zapisuje jako php oO (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif) nie za bardzo rozumiem. Folder gdzie obrazki sa pochowane nazywa sie upload i dalem chmod 777. a kod php do tego wyglada tak
Kod
         $data_obrazka = date('jmyhis');
         $katalog='upload/';
         $name = $katalog.$data_obrazka.'_'.$userfile_name;
         $dir = $userfile;
        
         if (move_uploaded_file($dir,$name)){
         echo('<img src="resizejpeg.php?file='.$name.'&jakosc=85&szerokosc='.$_POST['szerokosc'].'&wysokosc='.$_POST['wysokosc'].'">');


kolega mi powiedzial ze cos tam z biblioteka. Moze ktos tez mi wyjasni co i jak zeby bylo mozna zapisac obrazek na kompie??

Dziekuje bardzo (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
^(-.-)^
post
Post #2





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 4.09.2008

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


Cytat
(wydaje mi sie ze podajesz zla sciezke do pliku)



Mam dobra sciezke (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) dam tutaj caly kod tego resizejpeg.php

  1. <?php
  2.  
  3. $file = $_GET['file'];
  4. $jakosc = $_GET['jakosc'];
  5. $sze = $_GET['szerokosc'];
  6. $wys = $_GET['wysokosc'];
  7.  
  8. list($width, $height) = getimagesize($file);
  9. $new_width = $sze;
  10. $new_height = $wys;
  11. $image_p = imagecreatetruecolor($new_width, $new_height);
  12.  
  13. echo $sze;
  14.  
  15. preg_match("|.([a-z0-9]{2,4})$|i", $file, $fileSuffix);
  16. switch(strtolower($fileSuffix[1]))
  17. {
  18. case "jpg"<span style="color: #007700":
  19. header('Content-typ: image/jpeg');
  20. $image = imagecreatefromjpeg($file);
  21. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  22. imagejpeg($image_p, null, $jakosc);
  23. break;
  24. case "png"<span style="color: #007700":
  25. header('Content-typ: image/png');
  26. $image = imagecreatefrompng($file);
  27. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  28. imagepng($image_p, null, $jakosc);
  29. break;
  30. case "gif"<span style="color: #007700":
  31. header('Content-typ: image/gif');
  32. $image = imagecreatefromgif($file);
  33. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  34. imagegif($image_p, null, $jakosc);
  35. }
  36. ?>


a do upload fotki: upload.php

  1. <?php
  2. include('resizejpeg.php');
  3.  
  4.    if($_POST['R1'] == "V1")
  5.     {
  6. // $userfile - miejsce tymczasowej lokalizacji pliku na serwerze WWW
  7. $userfile = $_FILES['userfile']['tmp_name'];
  8.  
  9. // $userfile_name - nazwa pliku w systemie uzytkownika
  10. $userfile_name = $_FILES['userfile']['name'];
  11.  
  12. // $userfile_size - wielkosc pliku w bajtach
  13. $userfile_size = $_FILES['userfile']['size'];
  14.  
  15. // $userfile_type - typ pliku w systemie MIME, np. image/gif
  16. $userfile_type = $_FILES['userfile']['type'];
  17.  
  18. // $userfile_error - kod bledu zwiazanego z wysylaniem pliku
  19. $userfile_error = $_FILES['userfile']['error'];  
  20.  
  21. if($userfile_error == UPLOAD_ERR_OK){  
  22. if ($userfile_type != 'image/jpeg' &&
  23. $userfile_type != 'image/png' &&
  24. $userfile_type != 'image/bmp' &&            
  25. $userfile_type != 'image/gif'){
  26.         $blad='Typ pliku jest b3edny. Mo?na umieszczaa tylko *jpg, *gif, *png lub *bmp.';
  27.     }
  28.  
  29. $data_obrazka = date('jmyhis');
  30. $katalog='upload/';
  31. $name = $katalog.$data_obrazka.'_'.$userfile_name;
  32. $dir = $userfile;
  33.  
  34. if (move_uploaded_file($dir,$name)){
  35. echo('<img src="resizejpeg.php?file='.$name.'&jakosc=85&szerokosc='.$_POST['szerokosc'].'&wysokosc='.$_POST['wysokosc'].'">');
  36.  
  37.  
  38.  
  39.  
  40. } else {$blad = 'Nie udano wrzucic zdjecia na serwer ';}
  41. } else {$blad = 'Inny blad ';} }
  42.  
  43.    if($_POST['R1'] == "V2")
  44.     {
  45.    echo('<img src="resizejpeg.php?file='.$_POST['userfile1'].'&jakosc=85&szerokosc='.$_POST['szerokosc'].'&wysokosc='.$_POST['wysokosc'].'">');
  46.     }
  47.  
  48.  
  49.  
  50. ?>


a z form mam

  1. <form method="POST" enctype="multipart/form-data" action="upload.php">


czytalem na stronie php o tym imagecolor. Ten blad co mi wyskakuje za kazdym razem jak uploaduje fotki.

Cytat
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/a8487159/public_html/resizejpeg.php on line 11


no i pisza tak.

Cytat
imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

Depending on your PHP and GD versions this function is defined or not. With PHP 4.0.6 through 4.1.x this function always exists if the GD module is loaded, but calling it without GD2 being installed PHP will issue a fatal error and exit. With PHP 4.2.x this behaviour is different in issuing a warning instead of an error. Other versions only define this function, if the correct GD version is installed.


wiec pytanie czy to wina serwera ktora nie jest platna?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) a jesli bede mial serwer wlasny czy mozna skonfigorowac tego GD2 (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) bo wtedy niby blad nie bedzie sie pojawil
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: 14.10.2025 - 21:01