Page 1 sur 3

Librairie GD

Posté : 11 déc. 2016, 23:04
par orell1
Bonjour à tous,

je n'arrive pas à afficher mon image GIF via la galerie GD, extension activée sur wamp.

Voici mes erreurs :
( ! ) Notice: Use of undefined constant ERR00 - assumed 'ERR00' in C:\wamp\www\2016\SITE\html\image.php on line 253
Call Stack
#	Time	Memory	Function	Location
1	0.0010	168584	{main}( )	..\image.php:0

( ! ) Notice: Use of undefined constant ERR01 - assumed 'ERR01' in C:\wamp\www\2016\SITE\html\image.php on line 253
Call Stack
#	Time	Memory	Function	Location
1	0.0010	168584	{main}( )	..\image.php:0

( ! ) Notice: Use of undefined constant ERR02 - assumed 'ERR02' in C:\wamp\www\2016\SITE\html\image.php on line 253
Call Stack
#	Time	Memory	Function	Location
1	0.0010	168584	{main}( )	..\image.php:0

( ! ) Notice: Use of undefined constant ERR03 - assumed 'ERR03' in C:\wamp\www\2016\SITE\html\image.php on line 253
Call Stack
#	Time	Memory	Function	Location
1	0.0010	168584	{main}( )	..\image.php:0

( ! ) Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\2016\SITE\html\image.php:253) in C:\wamp\www\2016\SITE\html\image.php on line 254
Call Stack
#	Time	Memory	Function	Location
1	0.0010	168584	{main}( )	..\image.php:0
2	0.2459	1267944	header ( )	..\image.php:254
GIF89aXXç#ƒÛì› B‰NÄüDBD_„¥c°šÌÛÿÿÿ9¤÷E˜ôÍ‘ "<cÇ@…Ê™çô)n`äü}¤¾ÿÿÿÿÿÿ'Ed„ƒ„ T±dcd|ÄÕÿÿÿa³ñ$"$”•”¶éúvÔüÿÿÿœ¯½0“îÌñüÿÿÿÿÿÿÿÿÿÿÿÿ4]sÓÃÌÔA”Þ3cˆC¶û8w*xɘüó˜Ýùÿÿÿ†ÊÚr´ÜÿÿÿÿÿÿO”ØÿÿÿXtÿÿÿb“´T‹ÿÿÿÿÿÿÿÿÿdÂöêÖÿÿÿCjÿÿÿ1t²ƒ’¤ÿÿÿdtŒÿÿÿÿÿÿ†äóÿÿÿÿÿÿÿÿÿ¸ýúÿÿÿÿÿÿˆÓð.…äl¦ÝP¬ó©èúÿÿÿLWaÿÿÿE¯ÌÍÏ–¢ªÿÿÿÍsGݝÇwÖ5~,¹òäu–/E^§YçÏ C‹†ù’;—4Ÿ¾„Y3æuê^Ç®»¶gØ¢sç~ìr©Þ¤— NÜwñãÈI;þíØóäߐ{C'>œzòà¥$³NÍÙ4¥Ôß…þ|ÿ~iüJã)G_ž<ûR”Ä«7¯^ˆfõ‘QSV½ù5çuB` €ÿè߁þÍ&ہ Ö†`¯ à„œÙg¡iÚG ¬q(¡if¢ˆŽh „ÿQèaþQÈšŠ"`ƒÊè ‚4Þ˜ 9bÖ£™áŠ d‹6FH A&YoÍ!—]vú§Û•Q–"„–¨]ÂejZ'™•Ê56šsÍ¥©›™“•ioQGtŸµ)çuŁfgwb—&qub'œo[Úßy^ÆWž–ßÁg|â-%‡RJi{’. æ–ø wš§Ôq™kÛµfê©nvGcFÙª›þùÝÁe~ÛiVkw© ¡ë®º¦æë¯ÀúŠ«¯¼öšk°­q×á²¥+l­Í*‹ª©¬¡†™µÑ]¬væçj·—Mö-”¼‰šÙ˜ÿ•,²Ë&;í%±Á+¯~öuÙe“°ÁЧ~ÕÁi&––Öe)¶zù˜fÛ:·-›j¢É'Àâò&±rqF¬°Ä¢¹ïœëÙ1™€’»°È‚Ú«e¦–¢—2§“ÂWÊ8è1êhÌ—–"È¢œŠÚpZªÓï Y¥“”å‡.oð ]œÒm‡°¬g竵Ä[¬ˆëfmš…½vmlÖÎj-¶ØÎ{ôÁÙLåÆ7MrÓ€âY«µ]bMö¯¦]­þ°ú¥ÖwjÉ \”pû¶ÎÏ{|g˜”ªÁG®Æÿû/–‹eÆq n±åã 1å_L¸çàÎYš—‘:šh|3ÏÜò+-ÃŽ§Â{ΐ{i+v‡~ø–¤uæÚ­&ð«mýøÁjûí»v¹ZÍ«ÝcKb†öa˜ý÷à³û_ièj§¬’U‡xžÞ¼¾É>~ÝÇní½Ö§vI=gê({°ï—D“Jç>÷­ÍJ£ÃŽ¡tŸá ìSÓéVçÖ1ŁcW–¹ÌOWbS?÷¹Š‰ðMÑó]ãtÝAÊR^§$e;JCVãØT£V3«ÈÍê€þ’óc’w1ZÅdlŽf§-uïWº’¡Õ¼÷Äðm¯kV´b÷ªˆ?Ëp«ZmzZ~¨Ô§äô©ŒíS ýÖ·îl{ëJÿöæ¿‚ýŠ~Su 6»öÀ¿³Vÿ„Íš~Åþ«Je*Öu¿NÈ+‹µªÝ"¦7MöN{šÓyl›Sõ›ø©S\NhE•ú8¹ÝŒ:ìîÐQž¿œê×|´½78þä¨oÞ«ë¹ôp5¬à²îP:L34¤eLXäzêÆzL7T­1bÅs>pV{<Ôxªce$§{tJô?vE—vZbpÇw|L’¨|’ñ EHôuI×÷AGQcRbþb}ÏxÚçG7eæ…Pº6kåWã‡W´æIÞ$*A“>˜5yw y ðã•&v2ëp€Õzb‡š6p•s!úbµ°«Ê_"Jƒ$±¨”[«\þ ¦RÆ”½Je…½Ž”¤%×JÅZ&kŠTI–î%uš"l%†Ë†xŒòRÝ„yÃt2\S†.»`Ÿ9’•plø‘+Ê">³Qs¹DG´’!ŠoæäªºáÐÝC¹év ª+´q$gaE»¼ y°",(#Š0¾ËSøˆ šiW›iÆë]ßY§H)z5½ÅóÁÓV=&½7xW$÷ަ«Z9¡ ¦Eè½õˆho"S#wfÄ^²»µ†Ä¸ê‹“)[g-4§~ÛJA©­Bž067‘¨3M8Fåƒz² l4“±YGd¹ùrDαÀÀqp-?+Áþ˜!ºÀ‰ŒÒ9, qMt[þss=Z½šj'&™¨á»¬¥§Üƒiç9“5y&…Ó_ó1LˆT°„b‘dÆN›óµY¾,o5±N‘D„'´½¬¬@ÝÚ_†Ã1N{›‘ø;$5Z†(Œó»Ó;ËxÙ*=;‡¯ÉYG©¨hz˜’k.áÇó$¸T1’‘ùáÍù‘Ç’qА—Ði ¯PCqœ¡º‚œà+¢› ‘ÇB°Á©A“õÌ÷¼Ð?¡‹ÀpÛÁÀ” Ò€ ˜ÐðmÂp<£€ ¸[þ ‹`Ò Äð²PÐ-²á`ဉva‚‹)pþÊ]ÙVf«6­ARÙ“feѨ•[ú¤¹J¥S–^¢XkáW8v›l¥S\2`›Åº ‰ä&ÊV(hçÃ®”¼¹zäÖ7'9K•›4±YÞ‚R«R4›.ê ¹Cѹç, æ,P÷p ÄÐ=}È\‚°Á­Áy ©1ÓÐψL,–- õ|ÒÀЗ°—°ÐÝsp²€ ¯àà•!]Ûëp˜À ¥ÒŠ@wŠ€»äœwp²MÛ¥ ’AÚÑP þpÒ+p iÐÃA ¾Ë‰ Ñ \ †É?M¼œ<ÔzbIêSÜ›Uª¤È–p¯ªÊž|¥—X «Ö§”»Æ½_ZwLë¶ë£t˜D‚%iÑ“› ¤–®c‘Øs­ê𫁭­ºx 5¿æ’¨§Š‘ç&+¥×Es-Àm¤c`O¢×Íz<*çœÓÖmÁ¾ÂÒ òŒÈ—­ºô»¹RPÙ”ý+ÝÏà˜ší+½ÚiãÒÀÐõì•xüÛŸ Ò@ ðÛê ÒpÕAÒ ]p»ÛY΂1-ÝyÐØ¥pK®–ÜKnaN¼¢J¤19ÃDÝRž¥ßþAÚêW5Ê«Jåþ8&Ïàg–þ?Ÿ§¼Cö?‚ Mãtbd[D”v Íñ$v¼RƒÍÀ­²à©qݲ2NãC¾Á\ðã9þ+<îÙ\ÔôWnäOtÑBpÑyºïÄŠ »wpåÀÝÄV®A¶gW^ Ö~-2%º/Åæ\ %Ûíy€Z‰kLáð7ðý <ÇA)£Üv‡Ä_Ð#ŸÇOƒ¾WñçÃ–Ê ËAXe±bJV{÷P8Fó])X“a¢×–/³‹‹{Æß´ˆZêsê?0©>Tò2.ÌÑ-$>µŽâ”SÇxlθѾΊýãÙž­ÁŸþMº¢í+iÙöÁÙB>ȩҍÙEž3.|/È.Þ‚×žŠ@f: ð|Ï eOÒ²ÒÝ÷ÀÑyP i wpŠpPÚ±îÎ#EJ](PJ \.]’öhÝ:E¸. Œ—„xÄRÐ%Ž9žrRZu-]¾Tw'¦Ì;5mÚ,UóR)!9kÂÚ’æŸ>*¼DTàÍš¥\þ¤TêT 2…ÎdšUkÌ™\£röëU«C½zý jס?Ï®U«UáÍœlé2õÙ–é·<ý ¹Cé%ž„?úLZêáNÀŒû®ã{‡/OÉ‘k%štçÆþ}iâÄ;ëȺ…‹¶¬Ð«Õ lÝòÒ벦ŸÎ&6CÓ_wð°˜KiÅ/|D(¡ð_È# @ž‰.]Pú—柡KWmäõèÒ ­Cž<DÍP“ô<²rê—7CqÝYAi0!¦&b
et mon codage :
<?php
require('gif.class.php');
$animation = array();
$duree = array();
  
//define('LARGEUR', 600);
//define('HAUTEUR', 600);
/* * *******************************  * Parametre  * ********************************  */ 
$largeur = 600; /* longueur de l'image */ 
$hauteur = 600; /* hauteur de l'image */ 

$txt =  str_replace ("v&oelig;ux", "voeux", $_GET['fichier']); 
$txt = rawurlencode($txt);
$txt = str_replace('%92', '%27', $txt);
$txt = rawurldecode($txt);

/* * *******************************  * IMAGE 1  * ********************************  */ 
$image = imagecreate($largeur, $hauteur); 
/* Background */ 
$background = imagecolorallocate($image, 0, 255, 0);
$image= imagecreatefrompng('carte_voeux_2016/1.png'); //Notre joli fond :p 
/* Couleur du text */ 
if($_GET['couleur'] =='orange') {
$couleurTxt = imagecolorallocate($image, 238, 153, 26); 
} else {
$couleurTxt = imagecolorallocate($image, 19, 57, 92); 
}
/* texte à mettre dans l'image */ 

/* Taille du texte */ 
$font_size = 9; 
putenv('GDFONTPATH=' . realpath('.'));
$font = 'arial.ttf';
/* Hauteur et largeur des caratères */ 
$largeurCaractere = ImageFontWidth($font_size); 
$hauteurCaractere = ImageFontHeight($font_size); 
/* Longueur du texte (taille caratère X nombre de caractère) */ 
$largeurTxt = $largeurCaractere * strlen($txt); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
$positionCentreHor = ceil(($largeur - $largeurTxt) / 2); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
//$positionCentreVer = ceil(($hauteur - $hauteurCaractere) / 2); 
$positionCentreVer = 380; 
/* Ajout du texte au centre de l'image */ 

$angle = 0;
$text_length = 80;
$new_text = wordwrap($txt, $text_length, "<br />", true);
$text = str_replace('<br />', "\n", $new_text);
// $fontsize = 12;

// Get image Width and Height
$image_width = imagesx($image);  
$image_height = imagesy($image);

// Get Bounding Box Size
$text_box = imagettfbbox($font_size,$angle,$font,$text);

// Get your Text Width and Height
$text_width = $text_box[2]-$text_box[0];
$text_height = $text_box[7]-$text_box[1];

// Calculate coordinates of the text
$x = ($image_width/2) - ($text_width/2);
$y = ($image_height/2) - ($text_height/2);

// Add some shadow to the text
imagettftext($image, $font_size, 0, $x, 410, $couleurTxt, $font, $text);

ob_start();
imagegif($image);
$animation[] = ob_get_clean();
$duree[] = 50;
imagedestroy($image);

/* * *******************************  * IMAGE 2  * ********************************  */ 
$image = imagecreate($largeur, $hauteur); 
/* Background */ 
$background = imagecolorallocate($image, 0, 255, 0);
$image= imagecreatefrompng('carte_voeux_2016/2.png'); //Notre joli fond :p 
/* Couleur du text */ 
if($_GET['couleur'] =='orange') {
$couleurTxt = imagecolorallocate($image, 238, 153, 26); 
} else {
$couleurTxt = imagecolorallocate($image, 19, 57, 92); 
}
/* texte à mettre dans l'image */ 

/* Taille du texte */ 
$font_size = 9; 
putenv('GDFONTPATH=' . realpath('.'));
$font = 'arial.ttf';
/* Hauteur et largeur des caratères */ 
$largeurCaractere = ImageFontWidth($font_size); 
$hauteurCaractere = ImageFontHeight($font_size); 
/* Longueur du texte (taille caratère X nombre de caractère) */ 
$largeurTxt = $largeurCaractere * strlen($txt); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
$positionCentreHor = ceil(($largeur - $largeurTxt) / 2); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
//$positionCentreVer = ceil(($hauteur - $hauteurCaractere) / 2); 
$positionCentreVer = 380; 
/* Ajout du texte au centre de l'image */ 

$angle = 0;
$text_length = 80;
$new_text = wordwrap($txt, $text_length, "<br />", true);
$text = str_replace('<br />', "\n", $new_text);
// $fontsize = 12;

// Get image Width and Height
$image_width = imagesx($image);  
$image_height = imagesy($image);

// Get Bounding Box Size
$text_box = imagettfbbox($font_size,$angle,$font,$text);

// Get your Text Width and Height
$text_width = $text_box[2]-$text_box[0];
$text_height = $text_box[7]-$text_box[1];

// Calculate coordinates of the text
$x = ($image_width/2) - ($text_width/2);
$y = ($image_height/2) - ($text_height/2);

// Add some shadow to the text
imagettftext($image, $font_size, 0, $x, 410, $couleurTxt, $font, $text);

ob_start();
imagegif($image);
$animation[] = ob_get_clean();
$duree[] = 30;
imagedestroy($image);

/* * *******************************  * CREATION IMAGE  * ********************************  */   
$gif = new GIFEncoder($animation, $duree, 0, 2, 0, 0, 0, 'bin');
header ("Content-type: image/gif");
echo $gif->GetAnimation();
?>
Merci pour votre aide.

Re: Librairie GD

Posté : 12 déc. 2016, 00:49
par @rthur
Bonjour,
C:\wamp\www\2016\SITE\html\image.php on line 253
Y a quoi à la ligne 253 ?

Re: Librairie GD

Posté : 12 déc. 2016, 09:00
par orell1
Il y a ça : $gif = new GIFEncoder($animation, $duree, 0, 2, 0, 0, 0, 'bin');

Merci

Re: Librairie GD

Posté : 12 déc. 2016, 11:10
par @rthur
Et bien cherche dans ton code où est-ce que tu as défini les variables ERR00 à ERR03 car c'est là dessus que tu as un problème.

Re: Librairie GD

Posté : 12 déc. 2016, 11:19
par orell1
Tu parles de ça ? :
Class GIFEncoder { 
    var $GIF = "GIF89a";        /* GIF header 6 bytes    */ 
    var $VER = "GIFEncoder V2.05";    /* Encoder version        */ 

    var $BUF = Array ( ); 
    var $LOP =  0; 
    var $DIS =  2; 
    var $COL = -1; 
    var $IMG = -1; 

    var $ERR = Array ( 
        ERR00=>"Does not supported function for only one image!", 
        ERR01=>"Source is not a GIF image!", 
        ERR02=>"Unintelligible flag ", 
        ERR03=>"Does not make animation from animated GIF source", 
    );

Re: Librairie GD

Posté : 12 déc. 2016, 11:24
par @rthur
Maintenant recherche où est appelé le tableau $ERR dans le reste de ton code.
Et vérifie que quand une erreur est appelée le tableau est bien appelé avec des guillemets.
Exemple :
$ERR['ERR00'] et non pas $ERR[ERR00]

Re: Librairie GD

Posté : 12 déc. 2016, 12:04
par moogli
juste en passant la définition du tableau n'est pas correcte et c'est surement ce que tu dis php
<?php
 var $ERR = Array ( 
        'ERR00' => "Does not supported function for only one image!", 
        'ERR01' => "Source is not a GIF image!", 
        'ERR02' => "Unintelligible flag ", 
        'ERR03 => "Does not make animation from animated GIF source", 
    );
// php 5.6 +
 var $ERR = [
        'ERR00' => "Does not supported function for only one image!", 
        'ERR01' => "Source is not a GIF image!", 
        'ERR02' => "Unintelligible flag ", 
        'ERR03 => "Does not make animation from animated GIF source", 
]
à l'heure de php 7 il serait pas mal de virer les définitions avec var et d'utiliser la portée ;)

pour le reste je te laisse regarder les recommandations PSR-1 et 2 ;-)

dernière chose, utilise une fonction pour ton code de redimensionnement, tu va y gagner à pas le dupliquer (pas d'oublie de modification, pas de possible comportement différente entre les deux utilisations ...).

@+

Re: Librairie GD

Posté : 12 déc. 2016, 23:45
par orell1
Parfait cela fonctionne...!
Il fallait simplement mettre des '' à ERR00, ce qui donne 'ERR00'.

Savez-vous svp comment centrer un plusieurs lignes selon une taille d'image de 600x600 ?

J'ai fait ça :
/* Ajout du texte au centre de l'image */ 

$angle = 0;
$text_length = 100;
$new_text = wordwrap($txt, $text_length, "<br />", true);
$text = str_replace('<br />', "\n", $new_text);
// $fontsize = 12;

// Get image Width and Height
$image_width = imagesx($image);  
$image_height = imagesy($image);

// Get Bounding Box Size
$text_box = imagettfbbox($font_size,$angle,$font,$text);

// Get your Text Width and Height
$text_width = $text_box[2]-$text_box[0];
$text_height = $text_box[7]-$text_box[1];

// Calculate coordinates of the text
$x = ($image_width/2) - ($text_length/2);
$y = ($image_height/2) - ($text_height/2);

// Add some shadow to the text
imagettftext($image, $font_size, 0, $x, 150, $couleurTxt, $font, $text);
Mais toutes les lignes débutent au centre de l'image.

Merci !

Re: Librairie GD

Posté : 13 déc. 2016, 14:33
par moogli
Parfait cela fonctionne...!
Il fallait simplement mettre des '' à ERR00, ce qui donne 'ERR00'.
je n'en doutais pas :)

tu t'es trompé dans le calcul de l'absice ce n'est pas la taille du texte divisée par deux qu'il faut soustraireà la moitier de l'image mais la taille de la boite divisée par deux.
par ce que dans ton cas ton calcul revient toujours a
$x = ($largeur_img/2) - 20;

le bon calcul : $x = ($image_width/2) - ($text_width/2);
code qui fait ce que tu veux (a partir du tient et de la doc)
<?php
header('Content-Type: image/png');

// Création de l'image
$image = imagecreatetruecolor(600 , 600);

// Création de quelques couleurs
$white = imagecolorallocate($image, 255, 255, 255);
$grey = imagecolorallocate($image, 128, 128, 128);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, 599, 599, $white);
// Remplacez le chemin par votre propre chemin de police
$font = 'ArefRuqaa-Regular.ttf';

$angle = 0;
$text_length = 100;
$new_text = wordwrap('Powered by PHP ' . phpversion(), $text_length, "<br />", true);
$text = str_replace('<br />', "\n", $new_text);
$fontsize = 30;

// Get image Width and Height
$image_width = imagesx($image);
$image_height = imagesy($image);

// Get Bounding Box Size
$text_box = imagettfbbox($fontsize,$angle,$font,$text);

// Get your Text Width and Height
$text_width = $text_box[2]-$text_box[0];
// Calculate coordinates of the text
$x = ($image_width/2) - ($text_width/2);

// Add some shadow to the text
imagettftext($image, $fontsize, 0, $x, 150, $grey, $font, $text);
imagepng($image);
imagedestroy($image);
le fichier de font https://fonts.google.com/specimen/Aref+Ruqaa
ce qui donne l'image extra ordinaire suivante :
test.png
@+

Re: Librairie GD

Posté : 13 déc. 2016, 17:30
par orell1
Merci.
Malheureusement seule la première ligne est centrée :-(
En fait c'est tout le bloc texte qui commence au milieu de l'image...

Le texte ne se centre donc pas :-(

Merci par avance.

Re: Librairie GD

Posté : 13 déc. 2016, 23:58
par orell1
Personne ne sait ?
Merci par avance.

Re: Librairie GD

Posté : 14 déc. 2016, 09:25
par orell1
CE qui me rassure c'est que je ne suis pas le seul à ne pas trouver :-)

Re: Librairie GD

Posté : 14 déc. 2016, 09:43
par Spols
Si je me base sur cete exemple de la doc,
http://php.net/manual/fr/function.image ... php#100713
Il te faut gerer chaque ligne indépendament.

Re: Librairie GD

Posté : 14 déc. 2016, 12:31
par orell1
Merci.

Je viens d'essayer et toujours la même chose ...
<?php
require('gif.class.php');
$animation = array();
$duree = array();
  
//define('LARGEUR', 600);
//define('HAUTEUR', 600);
/* * *******************************  * Parametre  * ********************************  */ 
$largeur = 600; /* longueur de l'image */ 
$hauteur = 600; /* hauteur de l'image */ 

$txt =  str_replace ("v&oelig;ux", "voeux", $_GET['fichier']); 
$txt = rawurlencode($txt);
$txt = str_replace('%92', '%27', $txt);
$txt = rawurldecode($txt);

/* * *******************************  * IMAGE 1  * ********************************  */ 
$image = imagecreate($largeur, $hauteur); 
/* Background */ 
$background = imagecolorallocate($image, 0, 255, 0);
$image= imagecreatefrompng('carte_voeux_2016/1.png'); //Notre joli fond :p 
/* Couleur du text */ 
if($_GET['couleur'] =='blanc') {
$couleurTxt = imagecolorallocate($image, 255, 255, 255); 
} else {
$couleurTxt = imagecolorallocate($image, 19, 57, 92); 
}
/* texte à mettre dans l'image */ 

/* Taille du texte */ 
$font_size = 10; 
putenv('GDFONTPATH=' . realpath('.'));
$font = 'arial.ttf';
/* Hauteur et largeur des caratères */ 
$largeurCaractere = ImageFontWidth($font_size); 
$hauteurCaractere = ImageFontHeight($font_size); 
/* Longueur du texte (taille caratère X nombre de caractère) */ 
$largeurTxt = $largeurCaractere * strlen($txt); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
$positionCentreHor = ceil(($largeur - $largeurTxt) / 2); 
/* Recherche de la position horizontale centrale pour centrer le texte */ 
//$positionCentreVer = ceil(($hauteur - $hauteurCaractere) / 2); 
$positionCentreVer = 160;  
/* Ajout du texte au centre de l'image */ 

$angle = 0;
$text_length = 90;
$new_text = wordwrap($txt, $text_length, "<br />", true);
$text = str_replace('<br />', "\n", $new_text);
// $fontsize = 12;

// Get image Width and Height
$image_width = imagesx($image);  
$image_height = imagesy($image);

// Get Bounding Box Size
$text_box = imagettfbbox($font_size,$angle,$font,$text);

// Get your Text Width and Height
$text_width = $text_box[2]-$text_box[0];
$text_height = $text_box[7]-$text_box[1];

// Calculate coordinates of the text
$x = ($image_width/2) - ($text_width/2);
$y = ($image_height/2) - ($text_height/2);

$lines = explode('|', wordwrap($text, 75, '|'));

// Starting Y position
$y = 150;

// Loop through the lines and place them on the image
foreach ($lines as $line)
{
    imagettftext($image, $font_size, 0, $x, $y, $couleurTxt, $font, $line);

    // Increment Y so the next line is below the previous line
    $y += 50;
}

// Add some shadow to the text
//imagettftext($image, $font_size, 0, $x, $positionCentreVer, $couleurTxt, $font, $text);

ob_start();
imagegif($image);
$animation[] = ob_get_clean();
$duree[] = 35;
imagedestroy($image);


/*  */
/* * *******************************  * CREATION IMAGE  * ********************************  */   
$gif = new GIFEncoder($animation, $duree, 0, 2, 0, 0, 0, 'bin');
header ("Content-type: image/gif");
echo $gif->GetAnimation();
?>
Merci par avance pour votre aide.

Re: Librairie GD

Posté : 14 déc. 2016, 12:55
par orell1
en gros voici ce que ça me fait : http://dl.free.fr/getfile.pl?file=/LBZ2lLSG