Foros del Web » Programando para Internet » PHP »

Margen negro

Estas en el tema de Margen negro en el foro de PHP en Foros del Web. Cree un sistema de tumbails el problema esque este cuando sube la foto me crea un margen negro en la parte inferior y no pone ...
  #1 (permalink)  
Antiguo 30/03/2012, 13:27
Avatar de Lautaro_eb  
Fecha de Ingreso: mayo-2010
Ubicación: Bariloche, Argentina
Mensajes: 284
Antigüedad: 13 años, 10 meses
Puntos: 24
Margen negro

Cree un sistema de tumbails el problema esque este cuando sube la foto me crea un margen negro en la parte inferior y no pone la imagen por completo si me podrian ayudar a encontrar el problema se los agradeseria.

Código PHP:
Ver original
  1. function createFrom(){
  2.         if($this->ext == "jpg"  || $this->ext == "jpeg"){
  3.             return ImageCreateFromJPEG($this->image);
  4.         }else if($this->ext == "gif"){
  5.             return ImageCreateFromGIF($this->image);
  6.         }else if($this->ext == "png"){
  7.             return ImageCreateFromPNG($this->image);
  8.         }
  9.         return false;
  10.     }
  11. function resize($nwidth,$nheight = false){
  12. //     $rname = $this->dir."r".microtime(true).".png";
  13.         $rname = sprintf("%sr%d.png",$this->dit,microtime(true));
  14.         $image = $this->createFrom();        
  15.         //var_dump($image);
  16.         $height = imagesx($image);      
  17.         $width = imagesy($image);
  18.        
  19.         if(!$nheight){
  20.             $nwidth = $nwidth;
  21.             $nheight = round($height % $nwidth);
  22.         }
  23.         $thumb = imagecreatetruecolor($nwidth, $nheight);        
  24.         imagecopyresized($thumb,$image,0,0,0,0,$nwidth,$nheight,$width,$height);
  25.         sleep(3);
  26.         unset($image);      
  27.         imagePNG($thumb,$rname);        
  28.         return $rname;
  29.     }
__________________
Mi emprendimiento: Software BRC
Youtube: Tutoriales de programación y electrónica.
  #2 (permalink)  
Antiguo 30/03/2012, 15:04
Avatar de truman_truman  
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: Margen negro

pasa en las jpg o en las que tienen fondo transparente?
__________________
la la la
  #3 (permalink)  
Antiguo 30/03/2012, 15:42
Avatar de Lautaro_eb  
Fecha de Ingreso: mayo-2010
Ubicación: Bariloche, Argentina
Mensajes: 284
Antigüedad: 13 años, 10 meses
Puntos: 24
Respuesta: Margen negro

Buenas gracias por responder las imagenes no tiene tranparensia pero en jpeg susede lo mismo
__________________
Mi emprendimiento: Software BRC
Youtube: Tutoriales de programación y electrónica.
  #4 (permalink)  
Antiguo 31/03/2012, 02:33
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Margen negro

Este margen negro... como de cuantos pixeles es?

Supongo que el error está aquí:
Código PHP:
Ver original
  1. if(!$nheight){
  2.             $nwidth = $nwidth;
  3.             $nheight = round($height % $nwidth);
  4.         }

Si deseas obtener el factor de conversión, creo que en esa función round sólo deberías involucrar anchos ($widht y $nwidth), después multiplicas (o divides?) el resultado por la altura original.

Sugerencia:
Usa una hoja de cálculo para probar esa fórmula y ajustarla (modificarla) hasta que obtengas el resultado deseado.
__________________
- León, Guanajuato
- GV-Foto

Etiquetas: margen, negro
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:54.