I am almost there - I can resize the image - it appears perfectly on my page at the right size only:
I don't want it to appear on my page I want it to be saved in a directory.
It is a .bmp and it started out as (and I want it to end up as) a jpeg.
<?
$path = $_SERVER['DOCUMENT_ROOT'] . '/fotos_coches_test/';
if(!empty($foto))
{
if ($foto_type == "image/gif") { $ext = ".gif"; }
if ($foto_type == "image/pjpeg") { $ext = ".jpg";}
$newfotoname = uniqid("").$ext ;
}
if (($foto_type == "image/gif") or ($foto_type == "image/pjpeg"))
{
header('Content-type: image/jpeg');
list ($width, $height) = getimagesize($foto);
$new_width=300;
$ratio=$new_width/$width;
$new_h=$ratio*$height;
$image_p = imagecreatetruecolor($new_width, $new_h);
$image = imagecreatefromjpeg($foto);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_h, $width, $height);
$im = imagejpeg($image_p, null, 75);
imagedestroy($image);
imagedestroy($image_p);
copy($im, $path.$newfotoname);
}
elseif (empty($foto))
{
$newfotoname = "ejemplo.gif";
}
?>
What´s wrong with the script?
Many many thanks.
Jon