Ankündigung

Einklappen
Keine Ankündigung bisher.

thumbnails erstellen

Einklappen

Neue Werbung 2019

Einklappen
Dieses Thema ist geschlossen.
X
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • #16
    Nein ausführen musst du die Funktion schon. Aber definiert ist sie IN der Schleife, das heißt bei jedem Schleifendurchlauf wird die Funktion neu definiert. Irgendwo nicht so der Sinn oder?

    Schau mal GENAU hin welche Datei geöffnet werden soll.

    thumb_divers/thumb_.

    Existiert ein Bild das "thumb_." heißt?? Lass dir mal genau ausgeben welchen $source du an die Funktion übergibst.

    Kommentar


    • #17
      also thumb_. kann es nicht geben, das würde heißen das es ..jpg gibt, oder eine jpg ohne dateinamen.

      hm $source gibt aus: ...
      3 punkte

      heißt das, dass schon readdir versagt?

      Kommentar


      • #18
        Schau dir mal das Beispiel auf php.net zu readdir an. Da steht du nutzt genau die falsche Art wie diese Funktion zu nutzen ist.

        Kommentar


        • #19
          so hier nochmal das script. jetzt bekomm ich weder nen error, ne warnung noch nen echo von $source


          PHP-Code:
          <?PHP
          //error_reporting(0);
          $originalpath "divers";
          $thumbnail="thumb_";
          $thumbpath="$thumbnail"."$originalpath";
          $dest "$originalpath"."$thumbpath";

          $thumbpathdir "".$originalpath."/";

          if(!
          is_dir($originalpath.$thumbpath)) {
          mkdir("$thumbpathdir"."$thumbpath"777);
          } else { 
          $open=opendir($originalpath);
          while (
          false !== ($source readdir($open))) { 
              if (
          $source != "." && $source != "..") {
              echo 
          $source;
              function 
          cropImage($nw$nh$source$stype$dest) {
                  
          $size = @getimagesize($source);
                  
          $w $size[0];
                  
          $h $size[1];
                  switch(
          $stype) {
                      case 
          'gif':
                      
          $simg imagecreatefromgif($source);
                      break;
                      case 
          'jpg':
                      
          $simg imagecreatefromjpeg($source);
                      break;
                      case 
          'png':
                      
          $simg imagecreatefrompng($source);
                      break;
                  }
                  
          $dimg imagecreatetruecolor($nw$nh);
                  
          $wm $w/$nw;
                  
          $hm $h/$nh;
                  
          $h_height $nh/2;
                  
          $w_height $nw/2;
                  if(
          $w$h) {
                      
          $adjusted_width $w $hm;
                      
          $half_width $adjusted_width 2;
                      
          $int_width $half_width $w_height;
                      
          imagecopyresampled($simg,$dimg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
                  } elseif((
          $w $h) || ($w == $h)) {
                      
          $adjusted_height = @($h $wm);
                      
          $half_height $adjusted_height 2;
                      
          $int_height $half_height $h_height;
                      
          imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
                  } else {
                      
          imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
                  }
              
                  
          imagejpeg($dimg,$dest,100);
                  
          cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source");
                  }
                  } 
              }
          }


          if (
          is_dir($originalpath.$thumbpath)) {
              if (
          $open opendir($originalpath)) {
                  while ((
          $file readdir($open)) !== false) {
                              echo 
          "<a href=\"".$originalpath."/".$file."\" rel=\"lightbox\"><img style=\"float:left;\" src=\"".$originalpath."thumb_".$originalpath."thumb_".$file."\"></a>";

                  }
                  
          closedir($dh);
                  }
          }

          ?>

          Kommentar


          • #20
            ok das else nach dem mkdir war quark. ohne dies bekomm ich 2/3 bildern aus $source

            nun kommt folgendes:


            PHP-Code:
            IMAG0060.jpg
            Warning
            :  imagecopyresampled(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 55

            Warning
            :  imagejpeg(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 65
            IMAG0061
            .jpg
            Fatal error
            :  Cannot redeclare cropimage() (previously declared in /var/www/web1/html/file/fotos/index.php:31in /var/www/web1/html/file/fotos/index.php on line 31 

            Kommentar


            • #21
              Was du da veranstalltest ist das totale Chaos. Wieso hast du die Funktion IN der while() Schleife, wieso rufst du die Funktion REKURSIV auf? Warum alles so kompliziert und nicht sauber geschrieben ...

              Kommentar


              • #22
                klasse fragen...wieso bin ich nicht selber drauf gekommen das ganze korrekt zuschreibe!?.. oh man


                es ist egal wo ich die funktion hinschreibe, das klappt nirgendwo. darum sitzt die in dem paste irgendwo

                Kommentar


                • #23
                  NEIN es macht definitiv einen Unterschied. Du darfst sie auf KEINEN FALL in der While-Schleife schreiben!

                  Am besten gaaanz an den Anfang oder gaaaanz an das Ende, damit der restliche Code zusammen steht und nicht nen Teil vor und nen Teil nach der Funktion steht. Das zerrupft nur den Code.

                  Desweiteren kann es natürlich noch nicht funktionieren weil du noch andere Fehler hast. Diese müssen auch noch ausgebessert werden. Aber du musst erst mal Schritt für Schritt die Fehler beheben.

                  Also Funktion aus der Schleife nehmen, schauen wie readdir() funktioniert! Dann den Code bissl aufräumen, kommentieren und wieder hier posten!

                  Kommentar


                  • #24
                    naja wie ich schon sagt, ich hab die funktion an jeder position in und ausserhalb des while probiert, der fehler ist der gleiche und zur zeit der einzige fehler der mir angezeigt wird.

                    PHP-Code:
                    <?PHP
                    //error_reporting(0);
                    error_reporting(E_ALL);
                    // PFADE BILDEN
                    $originalpath "divers";
                    $thumbnail="thumb_";
                    $thumbpath="$thumbnail"."$originalpath";
                    $dest "$originalpath"."$thumbpath";
                    $thumbpathdir "".$originalpath."/";

                    // THUMB ORDNER ERSTELLEN
                    if(!is_dir($originalpath.$thumbpath)) {
                    mkdir("$thumbpathdir"."$thumbpath"0777);
                    }  

                    // THUMB ERSTELLEN
                    $open=opendir($originalpath);
                    while (
                    false !== ($source readdir($open))) { 
                        if (
                    $source != "." && $source != "..") {
                        echo 
                    $source;
                        function 
                    cropImage($nw$nh$source$stype$dest) {
                            
                    $size = @getimagesize($source);
                            
                    $w $size[0];
                            
                    $h $size[1];
                            switch(
                    $stype) {
                                case 
                    'gif':
                                
                    $simg imagecreatefromgif($source);
                                break;
                                case 
                    'jpg':
                                
                    $simg imagecreatefromjpeg($source);
                                break;
                                case 
                    'JPG':
                                
                    $simg imagecreatefromjpeg($source);
                                break;
                                case 
                    'png':
                                
                    $simg imagecreatefrompng($source);
                                break;
                            }
                            
                    $dimg imagecreatetruecolor($nw$nh);
                            
                    $wm $w/$nw;
                            
                    $hm $h/$nh;
                            
                    $h_height $nh/2;
                            
                    $w_height $nw/2;
                            if(
                    $w$h) {
                                
                    $adjusted_width $w $hm;
                                
                    $half_width $adjusted_width 2;
                                
                    $int_width $half_width $w_height;
                                
                    imagecopyresampled($simg,$dimg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
                            } elseif((
                    $w $h) || ($w == $h)) {
                                
                    $adjusted_height = @($h $wm);
                                
                    $half_height $adjusted_height 2;
                                
                    $int_height $half_height $h_height;
                                
                    imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
                            } else {
                                
                    imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
                            }
                        
                            
                    imagejpeg($originalpath/$dimg,$dest,100);
                                    

                            }
                            
                            } 
                    }
                    cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source");


                    // THUMBS AUSLESEN UND GALERIE BAUEN
                    if (is_dir($originalpath.$thumbpath)) {
                        if (
                    $open opendir($originalpath)) {
                            while ((
                    $file readdir($open)) !== false) {
                                        echo 
                    "<a href=\"".$originalpath."/".$file."\" rel=\"lightbox\"><img style=\"float:left;\" src=\"".$originalpath."thumb_".$originalpath."thumb_".$file."\"></a>";

                            }
                            
                    closedir($dh);
                            }
                    }

                    ?>
                    wie gesagt, 2 von 3 bilder werden gelesen:

                    IMAG0060.jpgIMAG0061.jpg
                    Fatal error: Cannot redeclare cropimage() (previously declared in /var/www/web1/html/file/fotos/index.php:35) in /var/www/web1/html/file/fotos/index.php on line 35

                    Kommentar


                    • #25
                      Nagut, wenn du nicht auf meinen Tipp hören willst, dann lass es eben bleiben!

                      Eine Funktion kann nicht mehrfach definiert werden, wird sie aber wenn sie in der Schleife steht.

                      Kommentar


                      • #26
                        Wie florian schon öfters erwähnt hat, darf man eine Funktion nur einmal deklarieren. Das sagt auch deine Fehlermeldung aus....

                        Setze die funktion am ende des Scriptes, und rufe sie in der While schleife nur mit
                        PHP-Code:
                        cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source"); 
                        auf! So schwer ist das gar nicht! Die Postings von uns musst du schon verstehen wollen!
                        [B]Mfg Tomtaz[/B]
                        [I]"Es soll jetzt diese Erfindung geben.... Kugel oder so heißt die. Ist so eine Art Suchmaschine..." [/I]:!::shock:

                        Kommentar


                        • #27
                          Ah jetzt seh ich erst was du gemacht hast.

                          Ich sagte die Funktion SELBER musst du außerhalb der Schleife definieren.
                          Der AUFRUF der Funktion muss natürlich IN der Schleife passieren ...

                          Weißt du überhaupt was Funktionen sind und wie sie funktionieren??

                          Kommentar


                          • #28
                            Damit dieses Thema jetzt mal zu einem ende kommt... Hier der Code, ohne das die besagte Fehlermeldung auftritt!
                            PHP-Code:
                            <?PHP
                            //error_reporting(0);
                            error_reporting(E_ALL);
                            // PFADE BILDEN
                            $originalpath "divers";
                            $thumbnail="thumb_";
                            $thumbpath="$thumbnail"."$originalpath";
                            $dest "$originalpath"."$thumbpath";
                            $thumbpathdir "".$originalpath."/";

                            // THUMB ORDNER ERSTELLEN
                            if(!is_dir($originalpath.$thumbpath))
                            {
                                
                            mkdir("$thumbpathdir"."$thumbpath"0777);
                            }  

                            // THUMB ERSTELLEN
                            $open=opendir($originalpath);
                            while (
                            false !== ($source readdir($open)))
                            {
                                if (
                            $source != "." && $source != ".."
                                {
                                   echo 
                            $source;
                                   
                            cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source");
                                }
                            }


                            // THUMBS AUSLESEN UND GALERIE BAUEN
                            if (is_dir($originalpath.$thumbpath))
                            {
                                if (
                            $open opendir($originalpath))
                                {
                                    while ((
                            $file readdir($open)) !== false)
                                    {
                                        echo 
                            "<a href=\"".$originalpath."/".$file."\" rel=\"lightbox\"><img style=\"float:left;\" src=\"".$originalpath."thumb_".$originalpath."thumb_".$file."\"></a>";
                                    }
                                    
                                    
                            closedir($dh);
                                }
                            }
                            function 
                            cropImage($nw$nh$source$stype$dest)
                            {
                                
                            $size = @getimagesize($source);
                                
                            $w $size[0];
                                
                            $h $size[1];
                                switch(
                            $stype)
                                {
                                    case 
                            'gif':
                                        
                            $simg imagecreatefromgif($source);
                                    break;
                                    case 
                            'jpg':
                                        
                            $simg imagecreatefromjpeg($source);
                                    break;
                                    case 
                            'JPG':
                                        
                            $simg imagecreatefromjpeg($source);
                                    break;
                                    case 
                            'png':
                                        
                            $simg imagecreatefrompng($source);
                                    break;
                                }
                                
                            $dimg imagecreatetruecolor($nw$nh);
                                
                            $wm $w/$nw;
                                
                            $hm $h/$nh;
                                
                            $h_height $nh/2;
                                
                            $w_height $nw/2;
                                if(
                            $w$h)
                                {
                                    
                            $adjusted_width $w $hm;
                                    
                            $half_width $adjusted_width 2;
                                    
                            $int_width $half_width $w_height;
                                    
                            imagecopyresampled($simg,$dimg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
                                } 
                                elseif((
                            $w $h) || ($w == $h))
                                {
                                    
                            $adjusted_height = @($h $wm);
                                    
                            $half_height $adjusted_height 2;
                                    
                            $int_height $half_height $h_height;
                                    
                            imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
                                } 
                                else 
                                {
                                    
                            imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
                                }
                                
                                
                            imagejpeg($originalpath/$dimg,$dest,100);
                            }
                            ?>
                            [B]Mfg Tomtaz[/B]
                            [I]"Es soll jetzt diese Erfindung geben.... Kugel oder so heißt die. Ist so eine Art Suchmaschine..." [/I]:!::shock:

                            Kommentar


                            • #29
                              ey florian was geht mit dir? du hast immer noch nicht verstanden das es hier das einsteigerforum ist? unglaublich. nochmal wenn ich wüsste worum es da geht wäre ich nicht hier! bin ja schon froh das ihr nicht wie andere einfach die lösung postet. aber wenigstens konnte man tomtaz antwort mal nachvollziehen. nur leider gehts dann erst los mit den errors wenn nur der funktions-aufruf im while steht.



                              PHP-Code:
                              <?PHP
                              //error_reporting(0);

                              // PFADE
                              $originalpath "divers";
                              $thumbnail="thumb_";
                              $thumbpath="$thumbnail"."$originalpath";
                              $dest "$originalpath"."$thumbpath";
                              $thumbpathdir "".$originalpath."/";


                              // THUMB ORDNER ERSTELLEN
                              if(!is_dir($originalpath.$thumbpath)) {
                              mkdir("$thumbpathdir"."$thumbpath"0777);
                              }  

                              // THUMB ERSTELLEN
                              $open=opendir($originalpath);
                              while (
                              false !== ($source readdir($open))) { 
                                  if (
                              $source != "." && $source != "..") {
                                  echo 
                              $source;
                                
                              cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source");
                                      } 
                              }

                              // THUMBS AUSLESEN UND GALERIE BAUEN
                              if (is_dir($originalpath.$thumbpath)) {
                                  if (
                              $open opendir($originalpath)) {
                                      while ((
                              $file readdir($open)) !== false) {
                                                  echo 
                              "<a href=\"".$originalpath."/".$file."\" rel=\"lightbox\"><img style=\"float:left;\" src=\"".$originalpath."thumb_".$originalpath."thumb_".$file."\"></a>";

                                      }
                                      
                              closedir($dh);
                                      }
                              }



                              // FUNKTION SCHREIBEN
                              function cropImage($nw$nh$source$stype$dest) {
                                      
                              $size = @getimagesize($source);
                                      
                              $w $size[0];
                                      
                              $h $size[1];
                                      switch(
                              $stype) {
                                          case 
                              'gif':
                                          
                              $simg imagecreatefromgif($source);
                                          break;
                                          case 
                              'jpg':
                                          
                              $simg imagecreatefromjpeg($source);
                                          break;
                                          case 
                              'JPG':
                                          
                              $simg imagecreatefromjpeg($source);
                                          break;
                                          case 
                              'png':
                                          
                              $simg imagecreatefrompng($source);
                                          break;
                                      }
                                      
                              $dimg imagecreatetruecolor($nw$nh);
                                      
                              $wm $w/$nw;
                                      
                              $hm $h/$nh;
                                      
                              $h_height $nh/2;
                                      
                              $w_height $nw/2;
                                      if(
                              $w$h) {
                                          
                              $adjusted_width $w $hm;
                                          
                              $half_width $adjusted_width 2;
                                          
                              $int_width $half_width $w_height;
                                          
                              imagecopyresampled($simg,$dimg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
                                      } elseif((
                              $w $h) || ($w == $h)) {
                                          
                              $adjusted_height = @($h $wm);
                                          
                              $half_height $adjusted_height 2;
                                          
                              $int_height $half_height $h_height;
                                          
                              imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
                                      } else {
                                          
                              imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
                                      }
                                  
                                      
                              imagejpeg($originalpath/$dimg,$dest,100);
                                              

                              }

                              ?>

                              IMAG0060.jpg
                              Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 81

                              Warning: imagejpeg(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 91
                              IMAG0061.jpg
                              Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 81

                              Warning: imagejpeg(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 91
                              thumb_divers
                              Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 86

                              Warning: imagejpeg(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 91
                              1216412166_1.jpg
                              Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 81

                              Warning: imagejpeg(): supplied argument is not a valid Image resource in /var/www/web1/html/file/fotos/index.php on line 91

                              wie kann das jpg file kein gültiges bild sein? lass mich raten, erst jetzt wirds richtig kompliziert?

                              Kommentar


                              • #30
                                Hallo dom, erst mal eines vorweg gesagt. Es ist richtig das dies das Einsteigerforum ist, aber dennoch MUSST du auf Tipps bzw. Verbesserungsvorschläge eingehen, ansonsten bringt das alles hier exakt 0!

                                Zum zweiten, habe ich dir einen Code präsentiert der Formatiert war. Ich weiß nicht ob du Lust hast, formatierten Code wieder unformatiert zu machen.

                                Die Fehlermeldungen sind doch eindeutig oder nichtt?

                                tausche die Zeile:
                                PHP-Code:
                                cropImage(225165"$originalpath/$source""""$thumbpath/$thumbnail"."$source"); 
                                mit folgender aus:
                                PHP-Code:
                                cropImage(225165$originalpath '/' $source'jpg'$thumbpath '/' $thumbnail $source ); 
                                aus

                                Das funktioniert aber nur wenn du jpg Bilder hast...
                                [B]Mfg Tomtaz[/B]
                                [I]"Es soll jetzt diese Erfindung geben.... Kugel oder so heißt die. Ist so eine Art Suchmaschine..." [/I]:!::shock:

                                Kommentar

                                Lädt...
                                X