Page 1 sur 1

Bandes blanches de part et d'autre des images

MessagePublié: 05 Déc 2010, 21:10
par petitspouces
Bonjour,
Je crée ce message car certains abordent ce problème dans d'autres post qui traitent d'autre chose. :oops:
Ce sera ainsi plus facile à trouver :lol:

Pour ceux qui seraient gênés par les bandes blanches ajouter pour que toutes les images soient dans les mêmes proportions, j'ai trouvé la solution sur le forum en anglais.
En fait, il y a 2 solutions.

    - La première : changer la couleur des bandes, les mettre de la même couleur que votre fond ( pensez à la modifier par la suite si vous changez votre font de page !!! )

    - La seconde : supprimer la fonction qui complète l'image avec des bandes pour lui garder ces proportions d'origine. Gros inconvénient : fini le bel alignement des images dans les listes

Solution 1 :
Rechercher le fichier system/library/image.php.
Si vous ne l'avez pas modifié, il faut modifier le code RVB "255, 255, 255" à la ligne 106
Code: Tout sélectionner
$background = imagecolorallocate($this->image, 255, 255, 255);


Solution 2 :
Dans le même fichier, remplacer
Code: Tout sélectionner
public function resize($width = 0, $height = 0) {
       if (!$this->info['width'] || !$this->info['height']) {
         return;
      }

      $xpos = 0;
      $ypos = 0;

      $scale = min($width / $this->info['width'], $height / $this->info['height']);
      
      if ($scale == 1) {
         return;
      }
      
      $new_width = (int)($this->info['width'] * $scale);
      $new_height = (int)($this->info['height'] * $scale);         
       $xpos = (int)(($width - $new_width) / 2);
         $ypos = (int)(($height - $new_height) / 2);
                     
          $image_old = $this->image;
        $this->image = imagecreatetruecolor($width, $height);
         
      $background = imagecolorallocate($this->image, 255, 255, 255);
       imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
   
        imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
        imagedestroy($image_old);
           
        $this->info['width']  = $width;
        $this->info['height'] = $height;
    }

par
Code: Tout sélectionner
        public function resize($width = 0, $height = 0) {
           if (!$this->info['width'] || !$this->info['height']) {
             return;
          }

          $xpos = 0;
          $ypos = 0;

          $scale = min($width / $this->info['width'], $height / $this->info['height']);
         
          if ($scale == 1) {
             return;
          }
         
          $new_width = (int)($this->info['width'] * $scale);
          $new_height = (int)($this->info['height'] * $scale);         
          $xpos = (int)(($width - $new_width) / 2);
          $ypos = (int)(($height - $new_height) / 2);

          $image_old = $this->image;
          $this->image = imagecreatetruecolor($new_width, $new_height);
         
          imagecopyresized($this->image, $image_old, 0, 0, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
          imagedestroy($image_old);

          $this->info['width']  = $new_width;
          $this->info['height'] = $new_height;
        }

Normalement, de la ligne 53 à 83

En cas de problème, vous pouvez me contacter en mp