Estoy intentando generar una imagen en cada pasada de un bucle para hacer una nota con el da y el mes de un evento en cuestion.
El bucle es el siguiente:
Cdigo PHP:
for ($i=0; $i < count($eventos); $i++) {
$evento = $eventos[$i];
$fecha = explode("-", $evento->fecha);
setlocale(LC_TIME ,"esp");
$fecha_imagen = mktime(0, 0, 0, $fecha[1], $fecha[2], $fecha[0]);
$fecha = strftime("%d %B (%a)", $fecha_imagen);
echo "<div class='evento'>";
echo "<img src='". genera_imagen($fecha_imagen); . "' atl='Fecha' />" . $evento->nombre;
echo "</div>";
...
Cdigo PHP:
function genera_imagen($timestamp) {
$imagen = imagecreatefromgif('path_a_la_imagen');
$color_negro = imagecolorallocate($imagen, 0, 0, 0);
$color_rojo = imagecolorallocate($imagen, 103, 16, 17);
$mes = strftime('%b', $timestamp);
$dia = strftime('%d', $timestamp);
$fuente_path = 'path_a_la_fuente';
imagefttext($imagen, 12, 14, 57, 37, $color_negro, $fuente_path, $mes);
imagefttext($imagen, 15, 14, 10, 10, $color_rojo, $fuente_path, $dia);
header("Content-type: image/png");
imagepng($imagen);
imagedestroy($imagen);
}
Cdigo:
He conseguido generar la imagen bien en un fichero (poniendo el segundo parmetro de imagepng pero no consigo generarla al vuelo (para evitar cargar innecesariamente imagenes al servidor)PNG IHDRdCPLTEGGGaaakkkqqqvvvzzz~~~***Ğ'## ECHD730-:61.&$(%d ; [Xnhjcd]KG_YZTVQRM52NI+(GBB=sJGX86{pi}vxpsk_YxtfC@¹ }u{ZU*⧜*uoɽƹףØzic߽<:9˶ڹǺ 캺TTSܚl{|y&tRNS@fKIDATxZ X[uF Z.x!H@܄I'ҴcϰgخKlj %e!x:m&JP4e B)' 2pʅy?r9?0eQ$tM'R9KJG)ʹ}*xH-f?>s5ӑwozcݻgzKGO_j9`Gˀ_f?\$dqx'u[ZFP2Ɇu)0L0 ĩΔq@!/Ŏf0gy2aAs"4>O8^o[,y[ 'χ={t3{ :< o_nkn{fs+b_Cӣ]o|Y Ko&BVU}M\G׃lj5^1@M L}>̰lThdEudCo\kv IBP*YB.....
Quiz sea imposible lo que pido. Alguna idea?