here is the code that i have used. It does its job apart from the image quality thing.
$url= $_FILES['url'];
$srcFileName = $_FILES['url']['tmp_name'];
$newFileName= "/v5/media/arts/thumbnails/".$_FILES['url']['name'];
resizeAndCopy($srcFileName, $newFileName, 164, 109);
$newFileNameFull = "/v5/media/arts/full/".$_FILES['url']['name'];
resizeAndCopy($srcFileName, $newFileNameFull, 654, 436);
The resizeAndCopy(...) method is outlined below.
function resizeAndCopy($sourceFileName, $destinationFileName, $maxWidth, $maxHeight)
{
$src_im = imagecreatefromjpeg($sourceFileName);
$srcHeight = imagesy($src_im);
$srcWidth = imagesx($src_im);
$height = imagesy($src_im);
$width = imagesx($src_im);
if($height>$maxHeight)
{
$x=(int)($maxHeight/($height/100));
$width = (int)($x*($width/100));
$height = $maxHeight;
}
if($width>$maxWidth)
{
$x = (int)($maxWidth/($width/100));
$height = (int)($x*($height/100));
$width = $maxWidth;
}
$dst_im = imagecreate($width, $height);
echo "$srcWidth, $srcHeight, $width, $height <br>";
echo "$sourceFileName, $destinationFileName";
imagecopyresized($dst_im, $src_im, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
imagejpeg($dst_im, $destinationFileName,100);
}
The url below shows what i mean by bad image quality.
http://www.micclub.co.uk/v5/arts.php
it used to be like this:http://www.micclub.co.uk/gallery/pic23.jpg
Ive had a look at the replies ive had but i cant seem to find what i need. Hope this information will help you to help me. 🙂
Thanks in advance
Kam