- Code: Select all
if ($_FILES['imagen_conclusiones']['type']=="image/jpeg"){
$img=imagecreatefromjpeg($nuevo_nombre);
$bx=imagesx($img);
$by=imagesy($img);
if ($by>290){
$my=290;
$mx=intval($my*$bx/$by);
$im=imagecreatetruecolor ($mx, $my);
imagecopyresampled ($im, $img, 0, 0, 0, 0, $mx, $my, $bx, $by);
imagejpeg($im,$nuevo_nombre,75);
}
}elseif ($_FILES['imagen_conclusiones']['type']=="image/png"){
$img=imagecreatefrompng($nuevo_nombre);
$bx=imagesx($img);
$by=imagesy($img);
if ($by>290){
$my=290;
$mx=intval($my*$bx/$by);
$im=imagecreatetruecolor ($mx, $my);
imagecopyresampled ($im, $img, 0, 0, 0, 0, $mx, $my, $bx, $by);
imagejpeg($im,$nuevo_nombre,75);
}
}elseif ($_FILES['imagen_conclusiones']['type']=="image/x-png"){
$img=imagecreatefrompng($nuevo_nombre);
$bx=imagesx($img);
$by=imagesy($img);
if ($by>290){
$my=290;
$mx=intval($my*$bx/$by);
$im=imagecreatetruecolor ($mx, $my);
imagecopyresampled ($im, $img, 0, 0, 0, 0, $mx, $my, $bx, $by);
imagejpeg($im,$nuevo_nombre,75);
}
}
... and so. The code resizes perfectly images EXCEPT for png . I have fixed that the problem is at the following line:
$img=imagecreatefrompng($nuevo_nombre);
but I´m sure that the code is correct. The PHP version is 5.0.2. Have tried also with 4.3 , but still doesn't work. And also tried to uninstall XAMPP 1.4.12 and install 1.4.9, but with the same results.
I don't know what more colud I try. Any suggestions would be greatly appreciated.
[/code]