Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/01/2012, 07:19
Mikelon85
 
Fecha de Ingreso: diciembre-2002
Ubicación: bilbao
Mensajes: 345
Antigüedad: 21 años, 11 meses
Puntos: 3
Respuesta: Problema con imgejpeg y guardado de imagen

no entiendo :(

Código PHP:
<?php
class resize_new_image {
    private 
$image_name;
    private 
$image_new_name;
    private 
$image_width_maxsize;
    private 
$image_height_maxsize;
    
    public function 
__construct($image_name,$image_new_name,$image_width_maxsize,$image_height_maxsize) {
        
$this->image_name=$image_name;
        
$this->image_new_name=$image_new_name;
        
$this->image_width_maxsize=$image_width_maxsize;
        
$this->image_height_maxsize=$image_height_maxsize;
    }
    public function 
resize_image() {
        
//get original picture info
        
list($ancho_orig$alto_orig) = getimagesize($this->image_name);
        
$ratio_orig $ancho_orig/$alto_orig;
        if (
$this->image_width_maxsize/$this->image_height_maxsize $ratio_orig) {
               
$this->image_width_maxsize $this->image_height_maxsize *$ratio_orig;
        }
        else {
               
$this->image_height_maxsize $this->image_width_maxsize/$ratio_orig;
        }
        
//resize image
        
$image_p imagecreatetruecolor($this->image_height_maxsize$this->image_height_maxsize);
        
$image imagecreatefromjpeg($this->image_name);
        
imagecopyresampled($image_p$image0000$this->image_height_maxsize$this->image_height_maxsize$ancho_orig$alto_orig);
        
//create new image
        
imagejpeg($image_p$this->image_new_name100);
        echo 
"<img src='{$this->image_new_name}'>";
    }
}
$minipic = new resize_new_image("mikel.jpg","mini_mikel.jpg",100,100);
$minipic->resize_image();
$medpic = new resize_new_image("mikel.jpg","med_mikel.jpg",64,64);
$medpic->resize_image();
$iconpic = new resize_new_image("mikel.jpg","icon_mikel.jpg",32,32);
$iconpic->resize_image();
?>
me saca las imagenes con estos tamaños:

68x68
48x48
21x21

__________________
aste nagusia