Thanks for your reply ShawnK. I agree with you.
This function from my class doesn't seem to do crap, but the function that calls this function is working fine (it just uploads the image). I dont get any error messages and everything returns a value.
It is supposed to take my newly uploaded image from another function in my class and resize it if it is too big, and re-save it.
Any help would be awesome...
function thumbnails($source, $quality){
$this->source = $source;
$this->quality = $quality;
if((!$this->quality) || ($this->quality < 0)){
$this->quality = 75;
}
$size = getimagesize($this->source);
if(($size[0] >= 500) || ($size[1] >= 320)){
$scale = 2; //50% scale
} else {
$scale = 1; //No scaling
}
$w = $size[0] / $scale; // Width divided
$h = $size[1] / $scale; // Height divided
$resize = imagecreatetruecolor($w, $h); // Create a blank image
/* Check quality option. If quality is greater than 100, return error */
if ($this->quality > 100) {
$msg = 'The maximum quality is 100. Quality changes only affect JPEG images.';
return $msg;
} else {
switch ($size['mime']) {
case 'image/jpeg':
case 'image/jpg':
$im = imagecreatefromjpeg($this->source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, '', $this->quality); // Output the new JPEG
break;
case 'image/png':
$im = imagecreatefrompng($this->source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original PNG
imagepng($resize, '', $this->quality); // Output the new PNG
break;
}
imagedestroy($im);
return true;
}
}//end thumbnails function