<?php//nombre del archivo crearImg.phpif(empty($_GET["c"])){ $color = "#000000";}else{ $color = $_GET["c"];}function hex2rgb($hex) { if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $rgb = array($r, $g, $b); return $rgb;}$rgb = hex2rgb($color);
$im = ImageCreate(10,10);$black = ImageColorAllocate($im,$rgb[0],$rgb[1],$rgb[2]);ImageFilledRectangle($im,50,50,150,150,$black);header('Content-Type: image/png');ImagePNG($im);
?>
para ejecutar la función solo basta con ejecutar el archivo con el argumento, por ejemplo para un color rojo crearImg.php?c=ff0000
suerte a todos!
No hay comentarios:
Publicar un comentario