RobertP Posted February 13, 2012 Share Posted February 13, 2012 i have a few questions about generating thumbnails. 1. is it best to retain image quality/resolution by using a ratio for shrinking the width/height? example below 2. once i generate a thumbnail, does it make sense to store it on the server for access later? ratio example public static function generateThumbnail($file){ $w = 80;//80px width, height is relative header('Content-type: image/jpeg'); list($width,$height) = getimagesize($file); $ratio = $w/$width; $new_height = $height*$ratio; $image_p = imagecreatetruecolor($w,$new_height); $image = imagecreatefromjpeg($file); imagecopyresampled($image_p,$image,0,0,0,0,$w,$new_height,$width,$height); imagejpeg($image_p,null,100); } also, i store all my files outside of the web root, and access each one via a php script for downloading / viewing. i do this for security. some files are not blocked to normal members, and others blocked to guests. is this the best way for that? Quote Link to comment https://forums.phpfreaks.com/topic/256998-generating-thumbnails/ Share on other sites More sharing options...
scootstah Posted February 13, 2012 Share Posted February 13, 2012 1. Usually it's best to either crop or resize while maintaining aspect ratios. Otherwise, it's just going to look bad if you do a substantial resize. 2. Yes, it makes sense to store it on the server because generally image manipulations are costly. The less you need to do them the better. Quote Link to comment https://forums.phpfreaks.com/topic/256998-generating-thumbnails/#findComment-1317467 Share on other sites More sharing options...
RobertP Posted February 13, 2012 Author Share Posted February 13, 2012 thank you very much for your relpy. Quote Link to comment https://forums.phpfreaks.com/topic/256998-generating-thumbnails/#findComment-1317471 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.