Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][GD] Tworzenie miniaturek
Aysorth
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 31.12.2008

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


Hej,
posiadam ja sobie taki kod:
  1. <?php
  2.        function createthumb($file, $new_height = 200) {
  3.  
  4.                $name = explode('.', $file);
  5. if (preg_match("/jpg|jpeg/", $name[1])) {
  6. $image = imagecreatefromjpeg($file);
  7. } elseif (preg_match("/png/", $name[1])) {
  8. $image = imagecreatefrompng($file);
  9. } else {
  10. die("Podany plik musi być formatu .png, .jpg lub .jpeg.");
  11. }
  12.  
  13.                $width = imagesx($image);
  14. $height = imagesy($image);
  15.  
  16.                $new_width = ceil(($width*$new_height) / $height);
  17.  
  18.                $finalimg = imagecreatetruecolor($new_width, $new_height);
  19.  
  20.                imagecopyresized($finalimg, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height) or die();
  21.  
  22.                imagepng($img, "images/gallery/thumbnails/".$name[0].".png/");
  23.  
  24.                return $finalimg;
  25.  
  26.        }
  27. ?>


Wydaje mi się poprawny, jednak funkcja przy wywołaniu wyrzuca błąd:
imagecopyresized(): supplied argument is not a valid Image resource
Występuje on przy zmiennej $finalimg, 5 linijka od dołu.

Próbowałem różnie, ze stałymi wartościami wysokości i szerokości, imagecreate(), cały czas to samo. Co może być powodem tego błędu? Jak go zdeptać, opluć i wgnieść w ziemię?

Pracuję na
Apacz 2.2.6
PHP 5.25
GD 2.0.34
Win XP SP2

Pozdrawiam.
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: 8.10.2025 - 15:01