Foros del Web » Programando para Internet » PHP »

ini_set("memory_limit", "30M");

Estas en el tema de ini_set("memory_limit", "30M"); en el foro de PHP en Foros del Web. Buenas, basicamente me gustaría aumentar la memoria límite en un archivo .php puesto que quiero hacer que se pueda crear un texto encima de una ...
  #1 (permalink)  
Antiguo 27/10/2007, 06:40
Avatar de IMAC/  
Fecha de Ingreso: octubre-2005
Mensajes: 738
Antigüedad: 18 años, 6 meses
Puntos: 14
Sonrisa ini_set("memory_limit", "30M");

Buenas, basicamente me gustaría aumentar la memoria límite en un archivo .php puesto que quiero hacer que se pueda crear un texto encima de una imagen, y parece que no me da la memoria....

He intentado ésto con ini_set("memory_limit", "30M"); y luego cambiando de 30 a 40 o incluso puse 200....
Nada, que no me funciona...

Me da este error:
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 35 bytes) in /var/www/vhost/miweb.com/home/html/magen.php on line 65

¿Alguien sabe como puedo solucionarlo?

Por cierto, no tengo acceso al php.ini

Saludos. y gracias de antemano.
  #2 (permalink)  
Antiguo 27/10/2007, 07:41
Avatar de Seppo  
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
Re: ini_set("memory_limit", "30M");

31457280 bytes son 30M, justamente... O sea que aumenta la memoria, pero así y todo no le alcanza... probá aumentandola más, o verificando el código si podés "limpiar" un poco de espacio...
  #3 (permalink)  
Antiguo 27/10/2007, 09:13
Avatar de IMAC/  
Fecha de Ingreso: octubre-2005
Mensajes: 738
Antigüedad: 18 años, 6 meses
Puntos: 14
Re: ini_set("memory_limit", "30M");

Aunque ponga 200 o 300 no va, siempre dice que necesita más, lo cual es un poco absurdo para poner unas letras frente a una imagen...
  #4 (permalink)  
Antiguo 27/10/2007, 11:28
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: ini_set("memory_limit", "30M");

Que codigo estas utilizando?
  #5 (permalink)  
Antiguo 27/10/2007, 12:38
Avatar de IMAC/  
Fecha de Ingreso: octubre-2005
Mensajes: 738
Antigüedad: 18 años, 6 meses
Puntos: 14
Re: ini_set("memory_limit", "30M");

Lo saqué de un comentario de la página de php.net
No estoy seguro si lo estoy haciendo bien o no, pero me extraña que el fallo esté en la memoria...

Es algo tal que así:

Código PHP:
<?
ini_set
("memory_limit""30M");

//  Example of use...

//  This is a simple function to output text to an image
//  which is centered (as much as I want to do by eye)
//  and wrapped
//    Just remember that all the sizes are guessed
// doesn't cut on the space (only on number of characters)
//  or change color of text, but this isn't for that...
function imageCenterString$imgw$imgh,
   
$image_text ''$text_size=)
{
   
$im imagecreate$imgw$imgh );
   
   
// white background and blue text
   
$bg imagecolorallocate($im255255255);
   
$textcolor imagecolorallocate($im000);
   
   
$t_h $t_w $t_x $t_y 0;
   
$base_w =9$base_h 16;
   
$m 0.88;
   switch ( 
$text_size )
   {
      case 
1$t_w $base_w*pow(($m*.98),4);
         
$t_h $base_h*pow(($m*.98),4);
         break;
      case 
2$t_w $base_w*pow($m,3);
         
$t_h $base_h*pow($m,3);
         break;
      case 
3$t_w $base_w*pow($m,2);
         
$t_h $base_h*pow($m,2);
         break;
      case 
4$t_w $base_w*$m;
         
$t_h $base_h*$m;
         break;
      case 
5$t_w $base_w;
         
$t_h $base_h;
         break;
      default:
         if ( 
$text_size >= // set to 5
         
{   $t_w $base_w$t_h $base_h; }
         if ( 
$text_size // set to 1
         
{
            
$t_w $base_w*pow(($m*.98),4);
            
$t_h $base_h*pow(($m*.98),4);
         }
         break;
   }
   
   
$text_array = array();
   
   
$max floor($imgw/$t_w);
   
   for( 
$i=0strlen($image_text) > 0$i += $max)
   {
      
array_push($text_arraysubstr($image_text,0,$max));  // AQUÍ ME DA EL ERROR
      
if ( strlen($image_text) >= $max )
      {   
$image_text substr($image_text,$max); }
      else
      {   
$image_text 'no'; }
   }
   
   
$t_y = ($imgh/2) - ($t_h*count($text_array)/2);

   foreach ( 
$text_array as $text )
   {
      
$t_x = ($imgw/2)-($t_w*strlen($text)/2);
      
imagestring($im$text_size$t_x$t_y,
         
$text$textcolor);
      
$t_y += $t_h;
   }

   
// output the image
   
header("Content-type: image/gpeg");
   
imagejpeg($im);
}
imageCenterString(500,300,'hol'5);
?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 23:16.