anderson_catchme Posted August 21, 2014 Share Posted August 21, 2014 function create_image($ext, $filepath, $newfilepath, $jpegquality){switch ($ext){case "jpg" OR "jpeg": $im = @imagecreatefromjpeg($filepath); if($im){ imagejpeg($im, $newfilepath, $jpegquality);}break;case "gif": $im = @imagecreatefromgif($filepath); if($im){ imagegif($im, $newfilepath);}break;case "png": $im = @imagecreatefrompng($filepath); if($im){ imagepng($im, $newfilepath, 7);}break; }if(!$im){return FALSE; }} $ext is my file extention. The rest is pretty self explanitory. It's working for JPEG, but somehow not PNG or GIF. Not sure why, help appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted August 21, 2014 Solution Share Posted August 21, 2014 case "jpg" OR "jpeg":Can't do that. It's like saying if ($ext == ("jpg" OR "jpeg")) {which means if ($ext == true) {which will always be the case for strings like "jpg" or "png". Use multiple cases instead. case "jpg": case "jpeg": // ... Quote Link to comment Share on other sites More sharing options...
anderson_catchme Posted August 21, 2014 Author Share Posted August 21, 2014 Thanks. Working great now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.