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
|
<?php
header ("Content-type: image/png");
$police="polices/arial.ttf";
$file = 'images/test.png';
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num champs à la ligne $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
$image = @imagecreatefrompng($file)or die("Création impossible");
//$image = @ImageCreate (200, 100) or die ("Erreur lors de la création de l'image");
//couleur de fond blanc
$couleur_fond = ImageColorAllocate ($image, 255, 255, 255);
// couleurs Texte blanc, gris, noir
$white = imagecolorallocate($image, 255, 255, 255);
$grey = imagecolorallocate($image, 128, 128, 128);
$black = imagecolorallocate($image, 0, 0, 0);
//ajout du texte sur l'image
//variable image, variable taille police,variable angle,position en largeur, position en hauteur
imagettftext($image, 9, 0, 25, 60, $black, $police, stripslashes($data[0]));
imagettftext($image, 9, 0, 85, 60, $black, $police, stripslashes($data[1]));
imagettftext($image, 9, 0, 25, 75, $black, $police, stripslashes($data[2]));
imagettftext($image, 9, 0, 25, 90, $black, $police, stripslashes($data[3]));
imagettftext($image, 9, 0, 25, 105, $black, $police, stripslashes($data[4]));
imagettftext($image, 9, 0, 130, 105, $black, $police,stripslashes($data[5]));
imagettftext($image, 9, 0, 25, 120, $black, $police, stripslashes($data[6]));
imagepng ($image);
}
}
fclose($handle);
}
?> |
Partager