Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/01/2013, 00:41
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: insertar texto en diagonal a una grafico

Te dejo un ejemplo funcional del manual php:

Código PHP:
Ver original
  1. <?php
  2. header('Content-Type: image/jpg');
  3. $WatermarkNeeded = true;
  4. /* Get image info */
  5. $Image = @ImageCreateFromJPEG ("YourImage.jpg") ;
  6. $sx = imagesx($Image) ;
  7. $sy = imagesy($Image) ;
  8. if ($WatermarkNeeded)
  9.     {
  10.     /* Set text info */
  11.     $Text="Copyright Ben Clay" ;
  12.     $Font="arial.ttf" ;
  13.     $FontColor = ImageColorAllocate ($Image,255,255,255) ;
  14.     $FontShadow = ImageColorAllocate ($Image,0,0,0) ;
  15.     $Rotation = 30 ;
  16.     /* Make a copy image */
  17.     $OriginalImage = ImageCreateTrueColor($sx,$sy) ;
  18.     ImageCopy ($OriginalImage,$Image,0,0,0,0,$sx,$sy) ;
  19.     /* Iterate to get the size up */
  20.     $FontSize=1 ;
  21.     do
  22.         {
  23.         $FontSize *= 1.1 ;
  24.         $Box = @ImageTTFBBox($FontSize,0,$Font,$Text);
  25.         $TextWidth = abs($Box[4] - $Box[0]) ;
  26.         $TextHeight = abs($Box[5] - $Box[1]) ;
  27.         }
  28.     while ($TextWidth < $sx*0.7) ;
  29.     /*  Awkward maths to get the origin of the text in the right place */
  30.     $x = $sx/2 - cos(deg2rad($Rotation))*$TextWidth/2 ;
  31.     $y = $sy/2 + sin(deg2rad($Rotation))*$TextWidth/2 + cos(deg2rad($Rotation))*$TextHeight/2 ;
  32.     /* Make shadow text first followed by solid text */
  33.     ImageTTFText ($Image,$FontSize,$Rotation,$x+4,$y+4,$FontShadow,$Font,$Text);
  34.     ImageTTFText ($Image,$FontSize,$Rotation,$x,$y,$FontColor,$Font,$Text);
  35.     /* merge original image into version with text to show image through text */
  36.     ImageCopyMerge ($Image,$OriginalImage,0,0,0,0,$sx,$sy,50) ;
  37.     }
  38.  
  39. ImageJPEG ($Image) ;
  40. ?>

http://php.net/manual/en/function.im...text.php#70946

O también conozco esta clase ImageWorkshop, que hace casi lo mismo:

http://phpimageworkshop.com/tutorial...watermark.html

Saludos.
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP