par
chatainsim » 07 avr. 2006, 00:54
Bonjour, j'ai un probléme avec un script qui génére une image png.
Sur la version xampp de windows, cela fonctionne, mais sur lampp sur linux ça ne fonctionne plus, et je n'arrive pas à voir pk !
Si quelqu'un peut m'aider, voici le code de la page :
<?
session_start();
header("Content-type: image/png");
include("config.php");
$fontsize = $_GET['fontsize'];
$fontfamily = $_GET['font'];
$background = $_GET['color_bg'];
$fontcolor = $_GET['fontcolor'];
$x = $_GET['size_x'];
$y = $_GET['size_y'];
$h = $fontsize+5;
$h2 = $h*'2';
$first = urlencode($_GET['line1']);
$second = urlencode($_GET['line2']);
$border = $_GET['border'];
$first= str_replace('$title',$_GET['title'],$first);
$first = urlencode($first);
$second = str_replace('$artist',$_GET['artist'],$second);
$second = urlencode($second);
//mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count] )
$source = imagecreatefrompng("../img/croche.png");
$im = imagecreate ($x, $y);
// fond blanc et texte blanc
//A remplacer par une fonction switch
if ($background == 'white') { $bg = imagecolorallocate($im, 255, 255, 255); }
if ($background == 'blue') { $bg = imagecolorallocate($im, 0, 0, 255); }
//....
if ($fontcolor == 'white') { $textcolor = imagecolorallocate($im, 255, 255, 255); }
if ($fontcolor == 'blue') { $textcolor = imagecolorallocate($im, 0,0, 255); }
//...
$noir = imagecolorallocate($im, 0, 0, 0);
$text = "".$first."";
$text1 = "".$second."";
imagettftext($im, $fontsize, 0, 52, $h, $textcolor, "./font/".$fontfamily.".ttf", $text);
imagettftext($im, $fontsize, 0, 52, $h2, $textcolor, "./font/".$fontfamily.".ttf", $text1);
if ($border == 1)
{
ImageRectangle ($im, 0, 0, $x-1, $y-1, $noir);
}
imagecopymerge($im, $source, 1, 1, 0, 0, 50, 50, 100);
imagepng($im);
$miniature = "../img/user/mcdb_".md5($_SESSION['pseudo']).".png";
Imagepng($im, $miniature);
?>
Bonjour, j'ai un probléme avec un script qui génére une image png.
Sur la version xampp de windows, cela fonctionne, mais sur lampp sur linux ça ne fonctionne plus, et je n'arrive pas à voir pk !
Si quelqu'un peut m'aider, voici le code de la page :
[php]<?
session_start();
header("Content-type: image/png");
include("config.php");
$fontsize = $_GET['fontsize'];
$fontfamily = $_GET['font'];
$background = $_GET['color_bg'];
$fontcolor = $_GET['fontcolor'];
$x = $_GET['size_x'];
$y = $_GET['size_y'];
$h = $fontsize+5;
$h2 = $h*'2';
$first = urlencode($_GET['line1']);
$second = urlencode($_GET['line2']);
$border = $_GET['border'];
$first= str_replace('$title',$_GET['title'],$first);
$first = urlencode($first);
$second = str_replace('$artist',$_GET['artist'],$second);
$second = urlencode($second);
//mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count] )
$source = imagecreatefrompng("../img/croche.png");
$im = imagecreate ($x, $y);
// fond blanc et texte blanc
//A remplacer par une fonction switch
if ($background == 'white') { $bg = imagecolorallocate($im, 255, 255, 255); }
if ($background == 'blue') { $bg = imagecolorallocate($im, 0, 0, 255); }
//....
if ($fontcolor == 'white') { $textcolor = imagecolorallocate($im, 255, 255, 255); }
if ($fontcolor == 'blue') { $textcolor = imagecolorallocate($im, 0,0, 255); }
//...
$noir = imagecolorallocate($im, 0, 0, 0);
$text = "".$first."";
$text1 = "".$second."";
imagettftext($im, $fontsize, 0, 52, $h, $textcolor, "./font/".$fontfamily.".ttf", $text);
imagettftext($im, $fontsize, 0, 52, $h2, $textcolor, "./font/".$fontfamily.".ttf", $text1);
if ($border == 1)
{
ImageRectangle ($im, 0, 0, $x-1, $y-1, $noir);
}
imagecopymerge($im, $source, 1, 1, 0, 0, 50, 50, 100);
imagepng($im);
$miniature = "../img/user/mcdb_".md5($_SESSION['pseudo']).".png";
Imagepng($im, $miniature);
?>
[/php]