Forum Moderators: coopster
here is what i have..
function imgresize($img){
// Load image
$image = @imagecreatefromjpeg($img);
if ($image === false) { die ('Unable to open image'); }
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$pos = strpos($img,"BIG.jpg");
if($pos === false){
$new_width = 201;
$new_height = 158;
}
else{
$new_width = 531;
$new_height = 480;
}
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
can anyone explain what im doing rong.. as i feel i may not be understanding the functions properly.
thanks,
adrian
Sends direct to browser:
header('Content-type: image/jpeg');
[url=http://php.net/imagejpeg]imagejpeg[/url]($image_resized, null, 90);
Saves to disk:
$filepath = $_SERVER['DOCUMENT_ROOT'].'/imgs/resized/'.$img;
[url=http://php.net/imagejpeg]imagejpeg[/url]($image_resized, $filepath, 90);
i had already tried what you have written.. though seeing you say this and probably having the weekend to take my mind off it for abit has made me look into what else i could be doing wrong, but clearer as i never spotted it before.
I was using the wrong variable for the filepath! Foolish lol!..
thanks alot, works all fine and dandy now! :D