Schlo_50 Posted May 21, 2008 Share Posted May 21, 2008 Hi guys, I have a question that I need answering, but cannot find the solution using Google. Im not sure if it's because I don't know the technical term for it or whether its something not many sites cover. Either way im sure one of the gurus here can help. I have a shopping cart which I use for commerce. The 'add new item' module allows me to upload an image of the item im selling. When an image is uploaded it creates a thumbnail which will be availble for viewing when a visitor is browsing the website. The problem im having is that my php and gd creates a thumbnail and keeps the aspect ratio (which is a good thing, to a degree) so when I have around 20 products on a page they all look un-aligned because of the size of the original images. What I want to do is somehow add a border or frame around the thumbs so that they appear to be aligned within their cells. An example of what im after is here: http://shop.oakleas.co.uk/epages/es110305.sf/en_GB/?ObjectPath=/Shops/es110305_shop I am hoping that this is something that can be implemented into my existing code which is below. Can somebody help me please? Im really stuck on this one! Thanks in advance. /*Begin Generate Thumbnail*/ $imagefile = "uploads/$file_name"; $max_height = 150; $max_width = 150; $folder = "thumbs"; $newname = $pid; $newname = "$newname.jpg"; $size = getimagesize($imagefile); $width = $size[0]; $height = $size[1]; if($width>$max_width){ $set_width = $max_width; $set_height = round($set_width*($height / $width)); } elseif($height>$max_height) { $set_height = $max_height; $set_width = round($set_height*($width / $height)); } else { $set_height = $height; $set_width = $width; } $image = ImageCreateFromJpeg($imagefile); $new_image = ImageCreateTrueColor($set_width, $set_height); ImageCopyResampled($new_image,$image,0,0,0,0,$set_width,$set_height,$width,$height); imagejpeg($new_image, $folder."/".$newname, 90); if(trim($_POST['category2']) != "Please Select (optional)"){ $afolder = "thumbs"; $bfolder = "uploads"; $anewname = $pid+1; $anewname = "$anewname.jpg"; $aimage = ImageCreateFromJpeg($imagefile); $anew_image = ImageCreateTrueColor($set_width, $set_height); ImageCopyResampled($anew_image,$aimage,0,0,0,0,$set_width,$set_height,$width,$height); imagejpeg($anew_image, $afolder."/".$anewname, 90); $bimage = ImageCreateFromJpeg($imagefile); $bnew_image = ImageCreateTrueColor($width, $height); ImageCopyResampled($bnew_image,$bimage,0,0,0,0,$width,$height,$width,$height); imagejpeg($bnew_image, $bfolder."/".$anewname, 90); } /*End Generate Thumbnail*/ Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted May 21, 2008 Share Posted May 21, 2008 Those boarders are done in the layout not the image. You just need to hack together some css on your output to achieve that effect. Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted May 22, 2008 Author Share Posted May 22, 2008 Does anybody know any place can get some more information on how to do that then? Im dying to know! Quote Link to comment Share on other sites More sharing options...
mlin Posted May 22, 2008 Share Posted May 22, 2008 I don't see your output, but trying to keep it as simple as possible: set your column's width to something fixed, and align your cells to the center. 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.