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

Bibliothèques et frameworks PHP Discussion :

[GD] Création d'image graphique


Sujet :

Bibliothèques et frameworks PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 54
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Par défaut [GD] Création d'image graphique
    Bonjour,

    jai recupere ce script afin d'avoir un thermometre.

    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
     
    <?php
    function thermGraph( $current, $goal, $width, $height, $font ) {
     
     $bar = 0.75;
     
     // create the image
     $image = ImageCreate($width, $height);
     $bg = ImageColorAllocate($image,255,255,255 );
     $fg = ImageColorAllocate($image,255,0,0);
     $tx = ImageColorAllocate($image,0,0,0);
     
     //  Build background
     ImageFilledRectangle($image,0,0,$width,$height,$bg);
     
     //  Build bottom bulb
     imagearc($image, $width/2, $height-($width/2), $width, $width, 0, 360, $fg);
     ImageFillToBorder($image, $width/2, $height-($width/2), $fg, $fg);
     
     //  Build "Bottom level
     ImageFilledRectangle($image, ($width/2)-(($width/2)*$bar), $height-$width, ($width/2)+(($width/2)*$bar), $height-($width/2), $fg );
     
     //  Draw Top Border
     ImageRectangle( $image, ($width/2)-(($width/2)*$bar), 0, ($width/2)+(($width/2)*$bar), $height-$width, $fg);
     
     //  Fill to %
     ImageFilledRectangle( $image, ($width/2)-(($width/2)*$bar), ($height-$width) * (1-($current/$goal)), ($width/2)+(($width/2)*$bar), $height-$width, $fg );
     
     //  Add tic's
     for( $k=25; $k<100; $k+=25 ) {
     
         ImageFilledRectangle( $image, ($width/2)+(($width/2)*$bar) -5, ($height-$width) - ($height-$width)*($k/100) -1, ($width/2)+(($width/2)*$bar) -1, ($height-$width) - ($height-$width)*($k/100) +1, $tx );
     
     
         ImageString($image, $font, ($width/2)+(($width/2)*$bar) +2, (($height-$width) - ($height-$width)*($k/100)) - (ImageFontHeight($font)/2), sprintf( "%2d", $k), $tx);
     }
     
     // Add % over BULB
     $pct = sprintf( "%d%%", ($current/$goal)*100 );
     
     ImageString( $image, $font+2, ($width/2)-((strlen($pct)/2)*ImageFontWidth($font+2)), ($height-($width/2))-(ImageFontHeight($font+2) / 2), $pct, $bg);
     
     
     // send the image
     header("content-type: image/png");
     imagepng($image);
    }
     
     thermGraph( $HTTP_GET_VARS["Current"], $HTTP_GET_VARS["Goal"], $HTTP_GET_VARS["Width"], $HTTP_GET_VARS["Height"], $HTTP_GET_VARS["Font"] );
     
    ?>


    gd est bien activé sur mon serveur, et avec jpgraph.
    J'arrive pas a trouvé le probleme.
    Merci.

    j'ai les message d'erreur :

    Warning: imagecreate() [function.imagecreate]: Invalid image dimensions in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 26

    Warning: imagecolorallocate(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 27

    Warning: imagecolorallocate(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 28

    Warning: imagecolorallocate(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 29

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 32

    Warning: imagearc(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 35

    Warning: imagefilltoborder(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 36

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 39

    Warning: imagerectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 42

    Warning: Division by zero in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 45

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 45

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 50

    Warning: imagestring(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 53

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 50

    Warning: imagestring(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 53

    Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 50

    Warning: imagestring(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 53

    Warning: Division by zero in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 57

    Warning: imagestring(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 59

    Warning: Cannot modify header information - headers already sent by (output started at L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php:59) in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 63

    Warning: imagepng(): supplied argument is not a valid Image resource in L:\Program files 2\wamp\www\maison\N4\habitation\Web-thermographes\thermometer3.php on line 65
    Merci.

  2. #2
    Membre Expert
    Avatar de Thes32
    Homme Profil pro
    Développeur PHP, .Net, T-SQL
    Inscrit en
    Décembre 2006
    Messages
    2 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Développeur PHP, .Net, T-SQL

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 379
    Par défaut
    Salut,
    que vaut $width et $height ?

  3. #3
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Bonjour,
    +1 Thes32
    Si $width et $height ont des valeurs, peut être qu'ils sont évalués comme string, dans ce cas, essaie de les caster un int.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $image = ImageCreate((int)$width, (int)$height);
    A+.

Discussions similaires

  1. Création d'imageS à partir de graphiques
    Par jbollagnier dans le forum Excel
    Réponses: 3
    Dernier message: 08/11/2007, 19h34
  2. [GD] recherche fonction de création d'images miniatures
    Par digger dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 18/11/2005, 21h12
  3. Création d'images 3d
    Par smyley dans le forum Autres Logiciels
    Réponses: 8
    Dernier message: 08/10/2005, 16h50
  4. Réponses: 2
    Dernier message: 29/03/2004, 18h29

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