Guest User

Untitled

a guest
Feb 12th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. function ri($fichier, $largeurn, $longueurn) {
  2.  
  3.     //VARIABLE D'ERREUR
  4.     global $error;
  5.  
  6.     //TAILLE EN PIXELS DE L'IMAGE REDIMENSIONNEE
  7.     $longueur = $largeurn;
  8.     $largeur = $longueurn;
  9.  
  10.     //TAILLE DE L'IMAGE ACTUELLE
  11.     $taille = getimagesize($fichier);
  12.      
  13.     //SI LE FICHIER EXISTE
  14.     if ($taille) {
  15.      
  16.         //SI JPG
  17.         if ($taille['mime']=='image/jpeg' ) {
  18.             //OUVERTURE DE L'IMAGE ORIGINALE
  19.             $img_big = imagecreatefromjpeg($fichier);
  20.             $img_new = imagecreate($longueur, $largeur);
  21.              
  22.             //CREATION DE LA MINIATURE
  23.             $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur);
  24.  
  25.             //COPIE DE L'IMAGE REDIMENSIONNEE
  26.             imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
  27.             imagejpeg($img_petite,$fichier);
  28.  
  29.         }
  30.          
  31.         //SI PNG
  32.         else if ($taille['mime']=='image/png' ) {
  33.             //OUVERTURE DE L'IMAGE ORIGINALE
  34.             $img_big = imagecreatefrompng($fichier); // On ouvre l'image d'origine
  35.             $img_new = imagecreate($longueur, $largeur);
  36.              
  37.             //CREATION DE LA MINIATURE
  38.             $img_petite = imagecreatetruecolor($longueur, $largeur) OR $img_petite = imagecreate($longueur, $largeur);
  39.  
  40.             //COPIE DE L'IMAGE REDIMENSIONNEE
  41.             imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
  42.             imagepng($img_petite,$fichier);
  43.  
  44.         }
  45.         // GIF
  46.         else if ($taille['mime']=='image/gif' ) {
  47.             //OUVERTURE DE L'IMAGE ORIGINALE
  48.             $img_big = imagecreatefromgif($fichier);
  49.             $img_new = imagecreate($longueur, $largeur);
  50.              
  51.             //CREATION DE LA MINIATURE
  52.             $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur);
  53.  
  54.             //COPIE DE L'IMAGE REDIMENSIONNEE
  55.             imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
  56.             imagegif($img_petite,$fichier);
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment