IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

script pour redimmensnionner image et taille maxi image


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut script pour redimmensnionner image et taille maxi image
    Bonjour,

    J'ai mon script d'envoi d'image qui marche trés bien mais cependant je voudrai lui rajouter 2 option ....

    1 - Control du poinds de l'image maxi a 600 Ko ca m'eviterai davoir des image de 8 MO ....
    2 - Redimmensionnement de la taille de l'image a 600 Pixels (la miniature est deja generer par le script ... ca m'evitera d'avoir des photo de 1600*1200 pixel a afficher sur le site et de m'enregsitrer l'image en 600 pixels en PNG .... j'ai essayer de faire comme la miniature mais je me suis embrouiller dans les variables ...



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
     
    $path_big = "image_up/photos_carnet";
    $path_thumbs = "$path_big/mini";
     
    //the new width of the resized image.
    $img_thumb_width = 100; // in pixel
     
    $extlimit = "yes"; //Do you want to limit the extensions of files uploaded (yes/no)
    //allowed Extensions
    $limitedext = array(".gif",".jpg",".png",".jpeg");
     
     
    //check if folders are Writable or not
    //please CHOMD them 777
    if (!is_writeable($path_thumbs)){
    die ("Erreur: Le dossier <b>($path_thumbs)</b> n'est pas accessible");
    }
    if (!is_writeable($path_big)){
    die ("Erreur: Le dossier <b>($path_big)</b> n'est pas accessible");
    }
     
    //if the for has submittedd////////////////////////////////
    if (isset($_POST['submit'])){
     
    foreach ($_FILES['imgfile']['tmp_name'] as $key => $value) {
    $file_tmp=$value;//nom reel de l'image 
     
    $file_type = $_FILES['imgfile']['type'][$key];
    $file_name = $_FILES['imgfile']['name'][$key];
    $file_size = $_FILES['imgfile']['size'][$key];
     
    //check file extension//////////////////////
    $ext = strrchr($file_name,'.');
    $ext = strtolower($ext);
    if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
    //echo "L'extension du fichier sélectionné n'est pas correcte. <br /><a href=\"#\">retour</a>";
    exit();
    }
     
    //get the file extension./////////////////////
    $getExt = explode ('.', $file_name);
    $file_ext = $getExt[count($getExt)-1];
     
     
    $sql  = mysql_query(" INSERT INTO up_image2 SET  nom_image ='$file_ext', id_auteur ='$id_auteur', rubrique = '$rubrique', description = 'blabla', id_parent  = '15' ") or die( mysql_error());
     
     
     
     
     
    //Recuperation du dernier id et renomage/////////////////
    $rand_name = mysql_insert_id(); 
     
     
    //get the new width variable.///////////////////////
    $ThumbWidth = $img_thumb_width;
     
    //keep image type///////////////////////////////
    if($file_size){
    if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
    $new_img = imagecreatefromjpeg($file_tmp);
    }elseif($file_type == "image/x-png" || $file_type == "image/png"){
    $new_img = imagecreatefrompng($file_tmp);
    }elseif($file_type == "image/gif"){
    $new_img = imagecreatefromgif($file_tmp);
    }
     
    //list width and height and keep height ratio.//////////////////////
    list($width, $height) = getimagesize($file_tmp);
    $imgratio=$width/$height;
    if ($imgratio>1){
    $newwidth = $ThumbWidth;
    $newheight = $ThumbWidth/$imgratio;
    }else{
    $newheight = $ThumbWidth;
    $newwidth = $ThumbWidth*$imgratio;
    }
     
     
    $resized_img = imagecreatetruecolor($newwidth,$newheight);
     
    imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    //save image
    Imagepng ($resized_img,"$path_thumbs/$rand_name _mini.png");
    ImageDestroy ($resized_img);
    ImageDestroy ($new_img);
     
     
    echo "<br>Image Thumb: <a href=\"$path_thumbs/$rand_name _mini.png\" target=\"_new\" >$path_thumbs/$rand_name _mini.png</a>";
     
     
     
    }
     
     
     
    //envoyer la grosse image/////////////////////
    move_uploaded_file ($file_tmp, "$path_big/$aaa/$rand_name.$file_ext");
     
    echo "<br>grosse image: <a href=\"$path_big/$rand_name.$file_ext\" target=\"_new\">$path_big/$rand_name.$file_ext</a>";
     
    echo "<br /><h3>merci</h3>";
    echo "<div class=\"alerte\">Merci <b><? $auteur ?></b>Merci</div>";
    }}
     
    }
    ?>

  2. #2
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    Salut,

    pour la taille :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    if($_FILES['imgfile']['size'] > 600000) {
       //traitement
    }

    non?

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Je ne sais pas trops ... ou faudrai t'il le mettre ?

  4. #4
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    Ah !

    Ok, je pensais que ct toi qui avais fais le script!

    Ben on va faire à la barbar comme le créateur du script !

    Juste après ca :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
    //echo "L'extension du fichier sélectionné n'est pas correcte. <br /><a href=\"#\">retour</a>";
    exit();
    }
    tu mets ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    if($file_size > 600000) {
    exit(); // image trop grosse
    }

    Ce n'est pas très propre mais bon, il aurait fallu faire différemment la gestion d'erreur!
    Là il n'y aucun message d'erreur quand il y en a une

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Ok merci de ta reponse, Comment faudrai t'il faire pour que les message d'erreur apparaisse ? C'est vrai que ceci n'est pas pratique du tous ....

    Sinon pour que sa me reduise ma grosse image en 600 pixels j'ai essayer ceci mais j'obtiens une image noir ... EDIT : Je pense que si on arrive a reduire les image qui sont envoyé par les champs uploads... la controle de la taille sera peu etre pas trops grave car une image de 600 pixels ne fera pas plusieur MO.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    /// MODIFICATION GROSSE IMAGE
     
    $ThumbWidth2 = $img_thumb_width2;
     
    //list width and height and keep height ratio GRANDE IMAGE .//////////////////////
    list($width, $height) = getimagesize($file_tmp);
    $imgratio=$width/$height;
    if ($imgratio>1){
    $newwidth2 = $ThumbWidth2;
    $newheight2 = $ThumbWidth2/$imgratio;
    }else{
    $newheight2 = $ThumbWidth2;
    $newwidth2 = $ThumbWidth2*$imgratio;
    }
     
     
    $resized_img2 = imagecreatetruecolor($newwidth2,$newheight2);
     
    imagecopyresized($resized_img2, $new_img, 0, 0, 0, 0, $newwidth2, $newheight2, $width, $height);
    //save image
    Imagepng ($resized_img2,"$path_big/3/$rand_name.png");
    ImageDestroy ($resized_img2);
    Mais je pense qu'il faudrai peu etre retrailler file_tmp ici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    //envoyer la grosse image/////////////////////
    move_uploaded_file ($file_tmp, "$path_big/$aaa/$rand_name.$file_ext");
    afin qu'on puisse reussir a reduire cette image plus proprement ... mais comment faire ?

  6. #6
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    De toute facon tu est obligé d'uploader l'image pour pouvoir la réduire!
    Tu ne peux pas le faire avant!


    Par contre j'allais t'écrire pour te dire de réutiliser le même code de redimensionnement de l'image pour en avoir une miniature, mais je vois que tu l'as dit avant moi!

    Fais attention, pense à libérer tes variables de la mémoire si tu utilises les mêmes!
    C'est peu etre du à ca ton bug!
    Sinon tu créer une fonction de redimensionnement que tu appelles deux fois, 1 première fois pour faire une miniature et une 2eme fois pour diminuer ton image.
    Mais Il est vrai que de faire le test de l'image > 600ko puis de redimensionner les images trop grosse est inutile!

    Le seul résultat que tu auras c'est un agrandissement vu que tu refuses toutes les images > à 600ko.

    En claire, il y a une des 2 conditions inutiles

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Merci de ta reponse,

    Effectivement les variable doivent foutre la merdouille ...

    J'ai pas compris ceci :

    Sinon tu créer une fonction de redimensionnement que tu appelles deux fois, 1 première fois pour faire une miniature et une 2eme fois pour diminuer ton image.

    Enfin sur le principe j'ai compris mais apres ....

    Une premiere fois avec
    $img_thumb_width = 100;
    et la seconde vois avec
    $img_thumb_width = 600;

    Mais faire sa avec des fonction je ne sais pas faire ... (c'est une boucle ?)

    EDIT : Je viens di pensé mais si une photos envoyer par les champs uploads est inferrieur a 600 pixels il ne faudrai pas lui appliquer le redimmensionnement ?

  8. #8
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    ok!

    1ere reponse : Q = Comment appliquer 2 fois une fonction?
    R = dans ton code tu as la fonction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    function resize($max_weight) {
    
    /// MODIFICATION GROSSE IMAGE
    
    $ThumbWidth2 = $max_weight;
    
    //list width and height and keep height ratio GRANDE IMAGE .//////////////////////
    list($width, $height) = getimagesize($file_tmp);
    $imgratio=$width/$height;
    if ($imgratio>1){
    $newwidth2 = $ThumbWidth2;
    $newheight2 = $ThumbWidth2/$imgratio;
    }else{
    $newheight2 = $ThumbWidth2;
    $newwidth2 = $ThumbWidth2*$imgratio;
    }
    
    
    $resized_img2 = imagecreatetruecolor($newwidth2,$newheight2);
    
    imagecopyresized($resized_img2, $new_img, 0, 0, 0, 0, $newwidth2, $newheight2, $width, $height);
    //save image
    Imagepng ($resized_img2,"$path_big/3/$rand_name.png");
    ImageDestroy ($resized_img2);
    
    
    /** A compléter, genre tu retournes l'images ou je ne sais quoi pour pouvoir la sauvegarder
    
    va ici pour la doc sur les fonctions utilisés
    }

    Après le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    $path_big = "image_up/photos_carnet";
    $path_thumbs = "$path_big/mini";
    
    //the new width of the resized image.
    $img_thumb_width = 100; // in pixel
    
    $extlimit = "yes"; //Do you want to limit the extensions of files uploaded (yes/no)
    //allowed Extensions
    $limitedext = array(".gif",".jpg",".png",".jpeg");
    
    
    //check if folders are Writable or not
    //please CHOMD them 777
    if (!is_writeable($path_thumbs)){
    die ("Erreur: Le dossier <b>($path_thumbs)</b> n'est pas accessible");
    }
    if (!is_writeable($path_big)){
    die ("Erreur: Le dossier <b>($path_big)</b> n'est pas accessible");
    }
    
    //if the for has submittedd////////////////////////////////
    if (isset($_POST['submit'])){
    
    foreach ($_FILES['imgfile']['tmp_name'] as $key => $value) {
    $file_tmp=$value;//nom reel de l'image 
    
    $file_type = $_FILES['imgfile']['type'][$key];
    $file_name = $_FILES['imgfile']['name'][$key];
    $file_size = $_FILES['imgfile']['size'][$key];
    
    //check file extension//////////////////////
    $ext = strrchr($file_name,'.');
    $ext = strtolower($ext);
    if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
    //echo "L'extension du fichier sélectionné n'est pas correcte. <br /><a href=\"#\">retour</a>";
    exit();
    }
    
    //get the file extension./////////////////////
    $getExt = explode ('.', $file_name);
    $file_ext = $getExt[count($getExt)-1];
    
    
    $sql  = mysql_query(" INSERT INTO up_image2 SET  nom_image ='$file_ext', id_auteur ='$id_auteur', rubrique = '$rubrique', description = 'blabla', id_parent  = '15' ") or die( mysql_error());
    
    
    
    
    
    //Recuperation du dernier id et renomage/////////////////
    $rand_name = mysql_insert_id();
    
    resize(100);
    resize(600);
    Tu fais appelles deux fois de suite à la fonction resize()!

    ATTENTION!
    ICI JE T'EXPLIQUE LE PRINCIPE!
    NE FAIS PAS COPIER/COLLER Ca ne marcherait pas!


    Je ne te conseil pas de faire la sauvegarde de l'image dans la fonction resize()!
    Je te conseil de renvoyer l'image puis de la sauvegarder après!
    Tu comprends??
    Cela veut dire que tu dois avoir un return $image; qqpart dans ta fonction.

    Et puis j'ai vu aussi qu'il affichait le path de l'image et la fonction a besoin de l'id récupéré par la fonction mysql_insert_id(), donc si tu veux tjs afficher ce chemin, passe l'id en paramètre de la fonction!

    Si tu vraiment trop de mal redit le moi et je t'aiderai à coder tes fonctions !
    bon courage!

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Salut alors jai reussi a doublé la fonction en changeant et sa marche j'obtiens bien mon image en 600 pixel en suivant le ratio

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    //get the new width variable./////////////////////// GROSSSE IMAGE/////////////
    $ThumbWidth2 = $img_thumb_width2;
     
    //keep image type///////////////////////////////
    if($file_size){
    if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
    $new_img2 = imagecreatefromjpeg($file_tmp);
    }elseif($file_type == "image/x-png" || $file_type == "image/png"){
    $new_img2 = imagecreatefrompng($file_tmp);
    }elseif($file_type == "image/gif"){
    $new_img2 = imagecreatefromgif($file_tmp);
    }
     
    //list width and height and keep height ratio.//////////////////////
    list($width, $height) = getimagesize($file_tmp);
    $imgratio2=$width/$height;
    if ($imgratio2>1){
    $newwidth2 = $ThumbWidth2;
    $newheight2 = $ThumbWidth2/$imgratio2;
    }else{
    $newheight2 = $ThumbWidth2;
    $newwidth2 = $ThumbWidth2*$imgratio2;
    }
     
    $resized_img2 = imagecreatetruecolor($newwidth2,$newheight2);
     
    imagecopyresized($resized_img2, $new_img2, 0, 0, 0, 0, $newwidth2, $newheight2, $width, $height);
    //save image
    Imagepng ($resized_img2,"$path_big/$rand_name.png");
    ImageDestroy ($resized_img2);
    ImageDestroy ($new_img2);
     
    }
     
    echo "<br>Image grosse en 600: <a href=\"$path_big/$rand_name.png\" target=\"_new\" >$path_big/$rand_name.png</a>";
    echo "<br>Image Thumb: <a href=\"$path_thumbs/$rand_name _mini.png\" target=\"_new\" >$path_thumbs/$rand_name _mini.png</a>";
     
    }
    Pour la fonction j'ai pas trops compris ... je regarde ceci et j'essai de te mettre le code que j'obtiens

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Voila sa devrai donner qlq chose comme ceci ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    resize(100,$path_thumbs);
    resize(600,$path_big);

    et

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    function resize($max_weight,$chemin) {
     
    /// MODIFICATION GROSSE IMAGE
     
    $ThumbWidth2 = $max_weight;
     
    //list width and height and keep height ratio GRANDE IMAGE et petite .//////////////////////
    list($width, $height) = getimagesize($file_tmp);
    $imgratio=$width/$height;
    if ($imgratio>1){
    $newwidth2 = $ThumbWidth2;
    $newheight2 = $ThumbWidth2/$imgratio;
    }else{
    $newheight2 = $ThumbWidth2;
    $newwidth2 = $ThumbWidth2*$imgratio;
    }
     
    $resized_img2 = imagecreatetruecolor($newwidth2,$newheight2);
     
    imagecopyresized($resized_img2, $new_img, 0, 0, 0, 0, $newwidth2, $newheight2, $width, $height);
    //save image
    Imagepng ($resized_img2,"$chemin/$rand_name.png");
    ImageDestroy ($resized_img2);
     
    }
    le patch est en variable je pense ? Je n'est pas encore excétué ceci :p je verifie aupret des expert

    Quand tu dit return $images;
    cette ligne la enregistrre la photo la ou il faut non ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Imagepng ($resized_img2,"$chemin/$rand_name.png");

  11. #11
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    Il va te manquer qqs variables quand meme :p

    $rand_name


    AU fait tu as récupéré ca sur le site php.net???
    Parce que ya le meme code ici

  12. #12
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Re coucou

    J'ai edit pour rajouter certaine chose dans mon message precedent

    Sinon les varialble $width, $height, $rand_name sont deja defini avant non ?

  13. #13
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    Pour ton edit, oui cela enrgistre une copie exact !
    j'ai lu la doc de la fonction!

    Il ne te reste qu'a debuggé ta fonction!
    Je ne peux pas le faire pour toi :p!
    Je n'ai rien pour tester :p!

  14. #14
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    oula j'ai du mal a faire la fonction ...

    Euh non je n'est pas recueperer ceci sur le site je l'est trouver je ne sais plus ou .... Le code qui est sur la page que tu indique fai ceux que le code actuel fait aussi ?

    Arff :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Fatal error: Call to undefined function: resize() in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 129

  15. #15
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    function resize() {


    }


    Correctement écrite dans ton fichier???

    SInon tu créer un fichier fonctions.php

    Tu fais un petit require "fontions.php" en haut de ta page et tu appelles la fonction

  16. #16
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Re coucou

    Je ny arrive pas ... sa bug

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    Warning: Division by zero in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 135
     
    Warning: imagecreatetruecolor(): Invalid image dimensions in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 144
     
    Warning: imagecopyresized(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 146
     
    Warning: imagepng(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 148
     
    Warning: imagedestroy(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 149
     
    Warning: Division by zero in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 135
     
    Warning: imagecreatetruecolor(): Invalid image dimensions in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 144
     
    Warning: imagecopyresized(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 146
     
    Warning: imagepng(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 148
     
    Warning: imagedestroy(): supplied argument is not a valid Image resource in c:\documents and settings\stéph\bureau\site\lib\envoi_carnet.php on line 149

  17. #17
    Membre habitué Avatar de kodokan
    Profil pro
    Lycéen
    Inscrit en
    Avril 2006
    Messages
    127
    Détails du profil
    Informations personnelles :
    Âge : 32
    Localisation : France

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Avril 2006
    Messages : 127
    Points : 170
    Points
    170
    Par défaut
    Salut

    Ton erreur elle est peut-etre dût au fait que la librarie GD n'est pas activée dans php.ini
    Pour l'activer, recherche cette ligne dans php.ini

    supprime le ; devant est normalement ça marche

    ATTENTION : si tu utilise easyphp , fait la meme chose avec tous les fichier php.ini

  18. #18
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Salut

    La librairie est bien activée.

  19. #19
    Membre averti Avatar de Hug0_76
    Profil pro
    Inscrit en
    Août 2006
    Messages
    292
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 292
    Points : 332
    Points
    332
    Par défaut
    Les Warning sont claires pourtant !

    Division par 0 => Interdit, corrige donc ton code au niveau des divisons, tu dois surement avoir un pb de variable !

    Les paramètres des fonctions concernant les images sont à vérifier :p!

  20. #20
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 141
    Points : 39
    Points
    39
    Par défaut
    Bonsoir,

    Je n'arrive pas a faire la fonction ...

    Aussi j'ai pensé mais si la photo fait moins de 600 pixels il ne faut pas la redimensionner mais seulement la renomer au format JPG ...

    j'ai fait la condition

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if($width>600 OR $height>600 ){ // CONDITON DES 600 PIXELS
    Par contre comment on prend l'image (par exemple si c'est une PNG qu'il me la remete en JPG ... en gardant la taille normale (vu quelle fait moins de 600 Px)

    Si vous pourriez me donnez un coup de main

    Merci aux bonne ames.

Discussions similaires

  1. script pour déplacer image avec souris, pb avec Netscape
    Par jejerome dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 12/11/2006, 17h59
  2. Réponses: 3
    Dernier message: 17/08/2006, 11h30
  3. Fixer la taille maxi d'une image
    Par franck.thibault dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 14/08/2006, 13h00
  4. Lancement script pour pivoter des images
    Par steph_raynaud dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 27/04/2006, 13h18
  5. 1 script, pour animer une image, qui en regroupe 3 scripts
    Par vampyer972 dans le forum Général JavaScript
    Réponses: 13
    Dernier message: 09/04/2006, 00h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo