GdLib frage/gallery problem

cctnt

Erfahrenes Mitglied
Ich habe gerade ein galleryscript geschrieben das automatisch thumbnails erzeugt.

Mein problem ist, das die thumbnails zum kot*** ausschaun.

wie kann ich ein script von der gdlib version 1.6 auf die 2.0 umschreiben? bzw. kann es überhaupt daran liegen? Also das die Thumbnails so ecklig ausschaun.

Sie sind zum teil ohne farbe, zum Teil komplett falsche farben usw.
 
Du mußt dein PHP nur mit der GD-Lib 2.0 kompilieren und gut is.
Wenn du allerdings nen Shared Server hast, dann mußt du auf deinen Provider hoffen.


Die Funktionen dazu sind dann:
- imagecreatetruecolor
- imagecopyresampled

dann macht der auch schöne Thumbs! ;)
 
sry für dblpost.

Ich hab jetzt das problem das die Thumbnails schwarz sind.

Ich poste einfach mal die createthumg und die getthumb function
PHP:
  function createThumb($imgfile,$org_type,$org_width,$org_height,$thumb_width,$thumb_height) {
    switch ($org_type) {
      case 1 : 
        $im = imagecreatefromGIF($this->path_org.$imgfile); 
        break;
      case 2 : 
        $im = imagecreatefromJPEG($this->path_org.$imgfile);   
        break;
      case 3 : 
        $im = imagecreatefromPNG($this->path_org.$imgfile);   
		
        break;
    }
    if ($im) {
      if ($thumb = imagecreatetruecolor($thumb_width, $thumb_height))
	  {
       imagecopyresampled($thumb, $im, 0, 0, 0, 0, $thumb_width, $thumb_height,$org_width,$org_height);

        switch ($this->thumb_type) {
          case 1 : 
            $saved = imageGIF($thumb,$this->path_thumb.$imgfile);
            break;
          case 2 : 
            $saved = imageJPEG($thumb,$this->path_thumb.$imgfile,100);
            break;
          case 3 : 
            $saved = imagePNG($thumb,$this->path_thumb.$imgfile);
            break;
          default :
            $this->setError(1,'Thumbnailformat wird nicht unterstützt.');
            imagedestroy($im); 
            return false;           
        }
        imagedestroy($im);
        imagedestroy($thumb);
        if (!($saved)) {
          $this->setError(1,'Thumbnail konnte nicht gespeichert werden.');
          return false;              
        } else { 
          return true;
        }
      } else {
        $this->setError(1,'Thumbnail kann nicht erzeugt werden.');
        imagedestroy($im);
        return false;  
      }
    } else {
      $this->setError(1,'Bild kann nicht gelesen werden.');
      return false;
    }
  }
  
  function getThumb($filename) {
    $imgfile = basename($filename);
    if (file_exists($this->path_org.$imgfile) && 
        (strlen($imgfile) > 0)) {
      if (file_exists($this->path_thumb.$imgfile)) {
        $this->setError(0,'Thumbnail existiert bereits.');
        if (!$this->createall) {
          //Bestehenden Thumbnail wird verwendet
          return true;
        }
      } 
      list($org_width, $org_height, $org_type) = getimagesize($this->path_org.$imgfile);
      switch ($org_type) {
        case 1 : 
          if (!($this->imgtypes & IMG_GIF)) {
            $this->setError(1,'Bildformat GIF wird nicht unterstützt.');
            return false;          
          }
          break;
        case 2 :
          if (!($this->imgtypes & IMG_JPG)) {
            $this->setError(1,'Bildformat JPEG wird nicht unterstützt.');
            return false;          
          }
          break;        
        case 3 :
          if (!($this->imgtypes & IMG_PNG)) {
            $this->setError(1,'Bildformat PNG wird nicht unterstützt.');
            return false;          
          }
          break;        
        default :
          $this->setError(1,'Dieses Bildformat wird nicht unterstützt.');
          return false; 
      }    
      list($thumb_width,$thumb_height) = $this->calcSize($org_width, $org_height);
      if ($this->createThumb($imgfile,$org_type,$org_width,$org_height,$thumb_width,$thumb_height)) {
        return true;
      }      
    } else {
      $this->setError(1,'Datei nicht gefunden.');
      return false;    
    }  
  }

ich hoffe der code ist nicht zu lange.
 
Sind alle Bilder schwarz oder nur die GIFs? Seit der neueren GD-Generation wird nämlich das GIF-Format nicht mehr unterstützt.
 
sry für dblpost

Also

Ich hab es jetzt hingekriegt das die bilder richtig angezeigt werden.

nur werden sie ihn einer reihe mit blauem rand angezeigt.

wie kann ich das ändern?

PHP:
<?php 

  function getFiles($path) {
   $result = false;
   $dh=opendir($path);
   if ($dh) { 
     while ($file = readdir($dh)) { 
       if (eregi("(\.gif)|(\.jpg)|(\.jpeg)|(\.png)$",$file)) {
         $result[] = $file;
       }
     }
     closedir($dh);
   }
   return $result; 
 }
 
 require_once('./thumbnail.php');
 
 $imgpath = "./screens/";
 $errors = false;

 $files = getFiles($imgpath);
 
 if (is_array($files)) {
   $thumbnail = new thumbnail;
   $thumbnail->path_org = $imgpath;
   foreach($files as $file) {
     if ($thumbnail->getThumb($file)) {
       printf ("<a href=\"%s\"><img src=\"%s\"></a>", 
         $thumbnail->path_org.$file, $thumbnail->path_thumb.$file);     
     } else {
       $errors[$file] = $thumbnail->error['msg'];
     }
   }
   if (is_array($errors)) {
     foreach($errors as $key=>$val) {
       print ('<hr>Fehler<br>');
       printf('%s : %s', $key, $val);
     }
   }   
 } else {
   print ("No Files found.");
 }


?>

hier mal der code damit ihr euch alles besser vorstellen könnt
 
Original geschrieben von cctnt
nur werden sie ihn einer reihe mit blauem rand angezeigt.
(!) HTML-Grundbasics!

PHP:
/* ... */
printf("<a href=\"%s\"><img src=\"%s\" border=\"0\"></a><br />", $thumbnail->path_org.$file, $thumbnail->path_thumb.$file);
/* ... */
 
Zurück