Problema con
- HHawk
- Novice


- Registrado: Ago 13, 2009
- Mensajes: 22
- Status: Offline
Bueno esto es lo que estoy tratando de hacer.
Estoy tratando de que PHP para crear un texto a la imagen. Sin embargo, estoy con un problema pequeño. El fondo me está matando. Desde que lo uso en una imagen (gradiente de color), un fondo de color 1 será hacer que se vea feo.
Hacer transparente el fondo, que funciona parcialmente, hace que sea todavía se ven feos.
Ahora me preguntaba si podría un png pre-hechos de fondo que se utilizaría por debajo del texto generado. ¿Es eso posible? En caso afirmativo cómo.
Así es como actualmente se ve y funciona. Quiero agregar un fondo a la misma.
Por eso quiero saber si yo podría agregar un fondo fijo, por background.png ejemplo, a este archivo creado.
La razón por la que estoy usando PHP para hacer que el texto, es que los navegadores no soportan plenamente sombras (especialmente IE). Si no hay solución para esto, tendrá que utilizar texto sin formato. Suspiro...
¿Puede alguien por favor muéstrame cómo puedo añadir una imagen de fondo para el texto generado la imagen? Si su posible? Me falta el conocimiento de PHP para hacerlo yo mismo.
Gracias de antemano!
Estoy tratando de que PHP para crear un texto a la imagen. Sin embargo, estoy con un problema pequeño. El fondo me está matando. Desde que lo uso en una imagen (gradiente de color), un fondo de color 1 será hacer que se vea feo.
Hacer transparente el fondo, que funciona parcialmente, hace que sea todavía se ven feos.
Ahora me preguntaba si podría un png pre-hechos de fondo que se utilizaría por debajo del texto generado. ¿Es eso posible? En caso afirmativo cómo.
Así es como actualmente se ve y funciona. Quiero agregar un fondo a la misma.
Código: [ Select ]
<?php
setlocale(LC_TIME, "nl_NL");
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(260, 20);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$custom = imagecolorallocate($im, 35, 38, 41);
imagefilledrectangle($im, 0, 0, 300, 20, $white);
// The text to draw
#$text = "23 september 2010";
$text = strftime("%e %B'%y\n");
$text = strtoupper($text);
// Replace path by your own font path
$font = 'ras.otf';
// Add some shadow to the text
imagettftext($im, 14, 0, 1, 17, $grey, $font, $text);
imagettftext($im, 14, 0, 1, 19, $grey, $font, $text);
imagettftext($im, 14, 0, 0, 18, $grey, $font, $text);
imagettftext($im, 14, 0, 2, 18, $grey, $font, $text);
// Add the text
imagettftext($im, 14, 0, 1, 18, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
setlocale(LC_TIME, "nl_NL");
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(260, 20);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$custom = imagecolorallocate($im, 35, 38, 41);
imagefilledrectangle($im, 0, 0, 300, 20, $white);
// The text to draw
#$text = "23 september 2010";
$text = strftime("%e %B'%y\n");
$text = strtoupper($text);
// Replace path by your own font path
$font = 'ras.otf';
// Add some shadow to the text
imagettftext($im, 14, 0, 1, 17, $grey, $font, $text);
imagettftext($im, 14, 0, 1, 19, $grey, $font, $text);
imagettftext($im, 14, 0, 0, 18, $grey, $font, $text);
imagettftext($im, 14, 0, 2, 18, $grey, $font, $text);
// Add the text
imagettftext($im, 14, 0, 1, 18, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
- <?php
- setlocale(LC_TIME, "nl_NL");
- // Set the content-type
- header('Content-type: image/png');
- // Create the image
- $im = imagecreatetruecolor(260, 20);
- // Create some colors
- $white = imagecolorallocate($im, 255, 255, 255);
- $grey = imagecolorallocate($im, 128, 128, 128);
- $black = imagecolorallocate($im, 0, 0, 0);
- $custom = imagecolorallocate($im, 35, 38, 41);
- imagefilledrectangle($im, 0, 0, 300, 20, $white);
- // The text to draw
- #$text = "23 september 2010";
- $text = strftime("%e %B'%y\n");
- $text = strtoupper($text);
- // Replace path by your own font path
- $font = 'ras.otf';
- // Add some shadow to the text
- imagettftext($im, 14, 0, 1, 17, $grey, $font, $text);
- imagettftext($im, 14, 0, 1, 19, $grey, $font, $text);
- imagettftext($im, 14, 0, 0, 18, $grey, $font, $text);
- imagettftext($im, 14, 0, 2, 18, $grey, $font, $text);
- // Add the text
- imagettftext($im, 14, 0, 1, 18, $black, $font, $text);
- // Using imagepng() results in clearer text compared with imagejpeg()
- imagepng($im);
- imagedestroy($im);
- ?>
Por eso quiero saber si yo podría agregar un fondo fijo, por background.png ejemplo, a este archivo creado.
La razón por la que estoy usando PHP para hacer que el texto, es que los navegadores no soportan plenamente sombras (especialmente IE). Si no hay solución para esto, tendrá que utilizar texto sin formato. Suspiro...
¿Puede alguien por favor muéstrame cómo puedo añadir una imagen de fondo para el texto generado la imagen? Si su posible? Me falta el conocimiento de PHP para hacerlo yo mismo.
Gracias de antemano!
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Junio 1st, 2010, 1:41 am
- PaulR
- Newbie


- Registrado: Jul 10, 2010
- Mensajes: 5
- Status: Offline
Mira debajo del código, es una simple imagen de fondo que he creado después subido a mi servidor.
Basta con sustituir http://www.ozzu.com con www (dot) pulso-box (dot) com y el ejemplo funcionará prefectamenta.
Todo lo que usted realmente tiene que cambiar con su guión se cambie la línea siguiente:
Para el texto siguiente:
y debería funcionar, pero Im no seguro al 100% ya que no puede obtener su secuencia de comandos funciona correctamente gif "alt =": roll: "title =" Ojos del balanceo ">
Juega un poco con los dos guiones ver si puede hacerlo funcionar, si no me puede dar un PM
Gracias, PaulR.
Basta con sustituir http://www.ozzu.com con www (dot) pulso-box (dot) com y el ejemplo funcionará prefectamenta.
PHP Código: [ Select ]
header("Content-type: image/png"); // Set the correct header type, edit accordingly.
$imageURL = 'http://www.ozzu.com/downloads/background.png'; // Define the image URL, I have used a default one from my server.
$im = imagecreatefrompng($imageURL) // Create the image from the pre-defined URL
or die("Cannot Initialize new GD image stream"); // Throw error if unable to initialize image stream
imagealphablending($im, false); // Alpha image blending
imagesavealpha($im, true); // Save the Alpha blending
list($iWidth, $iHeight, $iType) = getimagesize($imageURL); // Get width, height and image type, can be used later on
$black = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 50, 50, 50); // Set the text color: Black
$white = imagecolorallocate($im, 255, 255, 255); // Set the text color: White
imagestring($im, 2, 5, 5, "Some Text Here", $white); // Create the text and write it to the image
imagestring($im, 2, 5, 20, "Some Text Here", $grey); // Create the text and write it to the image
imagestring($im, 2, 5, 35, "Some Text Here", $black); // Create the text and write it to the image
imagepng($im);
imagedestroy($im);
$imageURL = 'http://www.ozzu.com/downloads/background.png'; // Define the image URL, I have used a default one from my server.
$im = imagecreatefrompng($imageURL) // Create the image from the pre-defined URL
or die("Cannot Initialize new GD image stream"); // Throw error if unable to initialize image stream
imagealphablending($im, false); // Alpha image blending
imagesavealpha($im, true); // Save the Alpha blending
list($iWidth, $iHeight, $iType) = getimagesize($imageURL); // Get width, height and image type, can be used later on
$black = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 50, 50, 50); // Set the text color: Black
$white = imagecolorallocate($im, 255, 255, 255); // Set the text color: White
imagestring($im, 2, 5, 5, "Some Text Here", $white); // Create the text and write it to the image
imagestring($im, 2, 5, 20, "Some Text Here", $grey); // Create the text and write it to the image
imagestring($im, 2, 5, 35, "Some Text Here", $black); // Create the text and write it to the image
imagepng($im);
imagedestroy($im);
- header("Content-type: image/png"); // Set the correct header type, edit accordingly.
- $imageURL = 'http://www.ozzu.com/downloads/background.png'; // Define the image URL, I have used a default one from my server.
- $im = imagecreatefrompng($imageURL) // Create the image from the pre-defined URL
- or die("Cannot Initialize new GD image stream"); // Throw error if unable to initialize image stream
- imagealphablending($im, false); // Alpha image blending
- imagesavealpha($im, true); // Save the Alpha blending
- list($iWidth, $iHeight, $iType) = getimagesize($imageURL); // Get width, height and image type, can be used later on
- $black = imagecolorallocate($im, 0, 0, 0);
- $grey = imagecolorallocate($im, 50, 50, 50); // Set the text color: Black
- $white = imagecolorallocate($im, 255, 255, 255); // Set the text color: White
- imagestring($im, 2, 5, 5, "Some Text Here", $white); // Create the text and write it to the image
- imagestring($im, 2, 5, 20, "Some Text Here", $grey); // Create the text and write it to the image
- imagestring($im, 2, 5, 35, "Some Text Here", $black); // Create the text and write it to the image
- imagepng($im);
- imagedestroy($im);
Todo lo que usted realmente tiene que cambiar con su guión se cambie la línea siguiente:
PHP Código: [ Select ]
$im = imagecreatetruecolor(260, 20)
Para el texto siguiente:
PHP Código: [ Select ]
$im = imagecreatefrompng($imageURL)
y debería funcionar, pero Im no seguro al 100% ya que no puede obtener su secuencia de comandos funciona correctamente gif "alt =": roll: "title =" Ojos del balanceo ">
Juega un poco con los dos guiones ver si puede hacerlo funcionar, si no me puede dar un PM
Gracias, PaulR.
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 2 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 357 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
