Foros del Web » Programando para Internet » PHP »

problema magecreate con bmp

Estas en el tema de problema magecreate con bmp en el foro de PHP en Foros del Web. Hola amigos tengo un problema validando ancho y alto de un bmp el gif jpg jpeg y png funcionan muy bien pero el bmp me ...
  #1 (permalink)  
Antiguo 16/05/2008, 10:11
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
problema magecreate con bmp

Hola amigos tengo un problema validando ancho y alto de un bmp el gif jpg jpeg y png funcionan muy bien pero el bmp me arroja un error :/ o simplemente no funca segun he buscado puede ser ... del tipo
imagecreatefrombmp o
imagecreatefromwbmp
pero ninguno me resulta me manda error en la funcion un warning alguna sugerencia les dejo mi codigo que verifica alto y ancho de una imagen......


Código PHP:
<?php
//recibimos el tipo del archivo
$tipoimagen $_FILES['archivo']['type'];

//si es bmp preguntamos por alto y ancho
if ($tipoimagen == "image/bmp")
{
// Checamos las medidas 
$im=imagecreatefromwbmp($_FILES['archivo']['tmp_name']);
$ancho=imagesx($im);
$alto=imagesy($im);
if(
$ancho<=500 AND $alto<=400)
{
// Guardar imagen    
echo "<br>La imagen Cumple y es bmp";
}
else
{
echo 
"<br>La imagen no cumple las medidas, es muy grande";
}
///////////////////////////////////////////////////////////////////
}
?>
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #2 (permalink)  
Antiguo 16/05/2008, 11:17
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: problema magecreate con bmp

Hola kaninox,

¿Que tipo de Warning te lanza?

Saludos.
  #3 (permalink)  
Antiguo 16/05/2008, 11:23
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Respuesta: problema magecreate con bmp

ok

si pongo imagecreatefromwbmp me da :

Código:

Warning: imagecreatefromwbmp(): 'C:/Servidor/php/uploads/\php68.tmp' is not a valid WBMP file in e:\proyect\kaze\pruebas\index.php on line 226

Warning: imagesx(): supplied argument is not a valid Image resource in e:\proyect\kaze\pruebas\index.php on line 227

Warning: imagesy(): supplied argument is not a valid Image resource in e:\proyect\kaze\pruebas\index.php on line 228
supongo no puede saber las dimenciones :º raro por que en varios sites sale asi :/
si pongo imagecreatefrombmp me da :

Código:

Fatal error: Call to undefined function: imagecreatefrombmp() in e:\proyect\kaze\pruebas\index.php on line 226

esto en $im=imagecreatefromwbmp($_FILES['archivo']['tmp_name']);
???
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #4 (permalink)  
Antiguo 16/05/2008, 11:40
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: problema magecreate con bmp

Los archivos WBMP, son para dispositivos móviles, la librería GD no tiene soporte para imágenes BMP directamente, pero si ves en los comentarios de la función wmbp, puedes usar esta función para crear imágenes BMP:
Código PHP:
function imagecreatefrombmp$filename )
{
    
$file fopen$filename"rb" );
    
$read fread$file10 );
    while( !
feof$file ) && $read != "" )
    {
        
$read .= fread$file1024 );
    }
    
$temp unpack"H*"$read );
    
$hex $temp[1];
    
$header substr$hex0104 );
    
$body str_splitsubstr$hex108 ), );
    if( 
substr$header0) == "424d" )
    {
        
$header substr$header);
        
// Remove some stuff?
        
$header substr$header32 );
        
// Get the width
        
$width hexdecsubstr$header0) );
        
// Remove some stuff?
        
$header substr$header);
        
// Get the height
        
$height hexdecsubstr$header0) );
        unset( 
$header );
    }
    
$x 0;
    
$y 1;
    
$image imagecreatetruecolor$width$height );
    foreach( 
$body as $rgb )
    {
        
$r hexdecsubstr$rgb4) );
        
$g hexdecsubstr$rgb2) );
        
$b hexdecsubstr$rgb0) );
        
$color imagecolorallocate$image$r$g$b );
        
imagesetpixel$image$x$height-$y$color );
        
$x++;
        if( 
$x >= $width )
        {
            
$x 0;
            
$y++;
        }
    }
    return 
$image;

Saludos.
  #5 (permalink)  
Antiguo 16/05/2008, 11:49
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Respuesta: problema magecreate con bmp

yes si lo habia hecho man pero creia que habia una forma mas facil de solo ver el ancho y alto sin tener que convertir la imagen...

saludos y gracias master :)
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #6 (permalink)  
Antiguo 16/05/2008, 12:11
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: problema magecreate con bmp

Creo con getimagesize lo puedes realizar.

Saludos.
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.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:51.