Ver Mensaje Individual
  #111 (permalink)  
Antiguo 07/09/2011, 14:50
Avatar de iviamontes
iviamontes
 
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: [APORTE] Subir y redimensionar imagenes

modifiqué un poco el método, quedando así

Código PHP:
public function crop($width$height$margins false) {
        
$newImage imagecreatetruecolor($width$height);
        
$x $y 0;
    if ( 
$this->getHeight() > $this->getWidth() ){
            
$this->resizeToWidth($width);
        
$y = ($this->getHeight() - $height) / 2;
        }

        else if (
$this->getHeight() < $this->getWidth()){
            
$this->resizeToHeight($height);
            
$x = ($this->getWidth() - $width) / 2;
        }

        
imagecopy($newImage$this->_image00$x$y$width$height);
    
$this->_image $newImage;