Hello all. I am trying to write this very basic script to handle image thumbnails.
My problem is very simple, I dont know how to implement an OR clause in a switch.
With the code below, no matter if the image is a PNG or JPG it results in JPEG.
Any help is appreciated.
Thanks!
function thumbnails($source, $quality){
$this->source = $source;
$this->quality = $quality;
$img_size = getimagesize($source);
if(($img_size[0] >= 500) || ($img_size[1] >= 320)){
$scale = 2; //50% scale
} else {
$scale = 1; //No scaling
}
$img_h = $img_size[1] / $scale;
$img_w = $img_size[0] / $scale;
$resize = imagecreatetruecolor($img_w, $img_h);
if($this->quality > 100){
$msg = "Image quality is set too high. Maximum is 100.";
return $msg;
} else {
switch($img_size['mime']){
case "image/jpeg" || "image/jpg":
echo "Image is a JPEG";
break;
case "image/png":
echo "Image is a PNG";
break;
}//end switch
//imagedestroy($image);
}
}//end thumbnails function