ya consegui que funcionase, mediante las funciones GD de PHP.
con html no funcionaba xq al hacer echo con php no reconocia el width y height no se xq pero bueno con una clase de php q importe consegui q funcionase a la perfeccion y se puede utilizar para modificar las imagenes a cualkier tamaño conservando el aspect ratio. os la dejo aki por si os hace falta alguna vez
clase redimensionar
Código PHP:
Ver original<?PHP
class img_opt
{
var $max_width;
var $max_height;
var $path;
var $img;
var $new_width;
var $new_height;
var $mime;
var $image;
var $width;
var $height;
function max_width($width)
{
$this->max_width = $width;
}
function max_height($height)
{
$this->max_height = $height;
}
function image_path($path)
{
$this->path = $path;
}
function get_mime()
{
$this->mime = $img_data['mime'];
}
function create_image()
{
switch($this->mime)
{
case 'image/jpeg':
break;
case 'image/gif':
break;
case 'image/png':
break;
}
}
function image_resize()
{
$this->get_mime();
$this->create_image();
$this->width = imagesx($this->image); $this->height = imagesy($this->image); $this->set_dimension();
imagecopyresampled($image_resized, $this->image, 0, 0, 0, 0, $this->new_width, $this->new_height,$this->width, $this->height);
}
//######### FUNCTION FOR RESETTING DEMENSIONS OF IMAGE ###########
function set_dimension()
{
if($this->width==$this->height)
{
$case = 'first';
}
elseif($this->width > $this->height)
{
$case = 'second';
}
else
{
$case = 'third';
}
if($this->width>$this->max_width && $this->height>$this->max_height)
{
$cond = 'first';
}
elseif($this->width>$this->max_width && $this->height<=$this->max_height)
{
$cond = 'first';
}
else
{
$cond = 'third';
}
switch($case)
{
case 'first':
$this->new_width = $this->max_width;
$this->new_height = $this->max_height;
break;
case 'second':
$ratio = $this->width/$this->height;
$amount = $this->width - $this->max_width;
$this->new_width = $this->width - $amount;
$this->new_height = $this->height - ($amount/$ratio);
break;
case 'third':
$ratio = $this->height/$this->width;
$amount = $this->height - $this->max_height;
$this->new_height = $this->height - $amount;
$this->new_width = $this->width - ($amount/$ratio);
break;
}
}
}
?>
y aki os pongo el codigo de ejemplo para usarla:
Código PHP:
Ver original$obj = new img_opt();
$obj->max_width(190);
$obj->max_height(100);
$obj->image_path("foto.jpg");
$obj->image_resize();