Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1731 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  [PHP] ImageCreateFromJpeg - c'est possible de régler la compression ?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[PHP] ImageCreateFromJpeg - c'est possible de régler la compression ?

n°566238
Dawa
www.shootmeagain.com
Posté le 13-11-2003 à 23:31:17  profilanswer
 

cette fonction est bien bien pratique, je l'utilise dans un script qui crée des thumbnails qd j'uppe une image, mais la compression est vraiment crade et jme demandais s'il etait possible de la régler :o
 
merci !


---------------
SHOOT ME AGAIN WEBZINE
mood
Publicité
Posté le 13-11-2003 à 23:31:17  profilanswer
 

n°566405
JWhy
je peux plier (héhé)
Posté le 14-11-2003 à 05:50:44  profilanswer
 

je peux me tromper mais la qualité dependra de l'image que tu va loader, non ?
 
tu peux par contre modifier la compression si tu sauves/renvoie l'image modifiée avec ImageJPEG


---------------
www.alliancefrancophone.org ... Home is where the heart is
n°566415
darxmurf
meow
Posté le 14-11-2003 à 07:57:29  profilanswer
 
n°567826
Dawa
www.shootmeagain.com
Posté le 15-11-2003 à 23:11:23  profilanswer
 

ah bin c'est bien bon a savoir, merci bcp :d
 
par contre, jle place où dans ce script? :??:
 
 

Code :
  1. <?
  2. function thumbnail($file, $maxWidth, $maxHeight)
  3.   {
  4.    echo "<br>".$maxWidth."x".$maxHeight."<br>";
  5.    $prod=$maxWidth*$maxHeight;
  6.    echo $prod."<br>";
  7.      //Créé une image à partir de $file
  8.      $img = ImageCreateFromJpeg("pics/$file" );
  9.      //Dimensions de l'image
  10.      $imgWidth = imagesx($img);
  11.      $imgHeight = imagesy($img);
  12.      //Facteur largeur/hauteur des dimensions max
  13.      $whFact = $maxWidth/$maxHeight;
  14.      //Facteur largeur/hauteur de l'original
  15.      $imgWhFact = $imgWidth/$imgHeight;
  16.      //fixe les dimensions du thumb
  17.      if($imgWidth > $imgHeight)
  18.      {
  19.         //Si largeur déterminante
  20.         $thumbWidth  = $maxWidth;
  21.         $thumbHeight = $thumbWidth/$imgWhFact;
  22.        }
  23.        else
  24.        {
  25.         //Si hauteur déterminante
  26.         $thumbHeight = $maxHeight;
  27.         $thumbWidth = $thumbHeight*$imgWhFact;
  28. }
  29. echo "<br>".$thumbWidth."x".$thumbHeight."<br>";
  30.      //Créé le thumb (image réduite)
  31.      $imgThumb = ImageCreateTruecolor($thumbWidth, $thumbHeight);
  32.      //Insère l'image de base redimensionnée
  33.      ImageCopyResized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight);
  34.      //Nom du fichier thumb
  35.      $imgThumbName = "pics/small/".$file;
  36.      //Créé le fichier thumb
  37.      $fp = fopen($imgThumbName, "w" );
  38.      fclose($fp);
  39.      //Renvoie le thumb créé
  40.      ImageJpeg($imgThumb, $imgThumbName);
  41.      return $imgThumbName;
  42.   }
  43. ?>


---------------
SHOOT ME AGAIN WEBZINE
n°567973
JWhy
je peux plier (héhé)
Posté le 16-11-2003 à 01:48:34  profilanswer
 

la:

Code :
  1. //Renvoie le thumb créé, avec une qualité a 65%  
  2.      ImageJpeg($imgThumb, $imgThumbName, 65);


Message édité par JWhy le 16-11-2003 à 01:49:10

---------------
www.alliancefrancophone.org ... Home is where the heart is
n°568008
Dawa
www.shootmeagain.com
Posté le 16-11-2003 à 11:25:42  profilanswer
 

rho putaing cong j'avais meme pas vu :pfff:
 
 
merci beaucoup :jap: :hello:


---------------
SHOOT ME AGAIN WEBZINE

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  [PHP] ImageCreateFromJpeg - c'est possible de régler la compression ?

 

Sujets relatifs
Recherche webmaster Php ou autre, qui sache creer un admin[PHP] petit problème (validation de textarea)
Champs Multi valeurs possible sous SQL 2000?2 questions PHP : Créer une mini-image / comment faire une redirection
[PHP] Open_basedir et lien symbolique[PHP] Pb de recuperation de $var
[PHP] Mail tronqué avec mail()[PHP/JS] Associer un fichier à une variable PHP
[PHP] Question [MàJ] ¿[PHP / MySQL] Comment marche le LAST_INSERT_ID() ?
Plus de sujets relatifs à : [PHP] ImageCreateFromJpeg - c'est possible de régler la compression ?


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR