Hey. Lets say i have a 50kb image, which can be accessed by clicking a thumbnail. If i resized the image using html, will the size of the image decrease aswell? Or will it still be 50kb? If not, what is the best way to create thumbnails? Would i need to resize each image using a graphic editor and create a separate thumbnail for each? Thanks, Dan.
if you're using an html, the filesize will be the same. it just fix the ration to fit your imageplaceholder <IMG SCR=;;> it won't have any effect on filesize unless you manually edit the graphic to fit your thumbnail. or you could do an php imagecreate for an easy solutions. .....
Danago you may find this snippet from my site useful, it create a thumbnail, and a main image with a watermark, then saves them into seperate directories. $img = imagecreatefromjpeg("ORIGINALIMAGELOCATION"); $watermark = imagecreatefrompng("WATERMARK LOCATION"); $thumbnail = imagecreatefromjpeg("ORIGINALIMAGELOCATION"); $width = imagesx($img); $height = imagesy($img); $scale = min($maxWidth/$width, $maxHeight/$height); $tScale = min($maxTWidth/$width,$maxTHeight/$height); $newWidth = $scale*$width; $newHeight = $scale*$height; $tWidth = $tScale*$width; $tHeight = $tScale*$height; $watermarkWidth = imagesx($watermark); $watermarkHeight = imagesy($watermark); $dest_x = $newWidth - $watermarkWidth - 1; $dest_y = $newHeight - $watermarkHeight - 2; $tmpImage = imagecreatetruecolor($newWidth,$newHeight); $tmpThumb = imagecreatetruecolor($tWidth,$tHeight); imagecopyresampled($tmpImage,$img, 0,0,0,0, $newWidth,$newHeight,$width,$height); // main picture imagecopyresampled($tmpThumb,$thumbnail, 0,0,0,0, $tWidth,$tHeight,$width,$height); // thumbnail imagecopymerge($tmpImage,$watermark,$dest_x,$dest_y, 0, 0, $watermarkWidth,$watermarkHeight,100); //add watermark to main $thumbnail = $tmpThumb; $img = $tmpImage; // Only create image if it doesnt already exist... if(!file_exists("$mainDirectory/$filename")){ imagejpeg($img,"$mainDirectory/$filename",90); echo "Main Image Created."; }else{ echo "<FONT COLOR=\"FF0000\"> Main File Already Exists.</FONT>"; } if(!file_exists("$thumbDirectory/$filename")){ imagejpeg($thumbnail,"$thumbDirectory/$filename",90); echo "Thumbnail Created."; }else{ echo "<FONT COLOR=\"FF0000\"> Thumb Already Exists.</FONT>"; } imagedestroy($img); imagedestroy($watermark); imagedestroy($thumbnail); Code (markup): I copied this code from one of my own scripts, so there will be some variables that have been declared earlier on in the script, but they are pretty self-explanatory, if you don't understand what a variable is used for, PM me.