dylanb Posted February 2, 2009 Share Posted February 2, 2009 Hi can anyone tell me how i can apply an overlay to following thumbnail creation code, i want to overlay a white image with adjustable transparency, basically make the thumbnails faded; function file_thumb($file,$album,$file_name) { global $thumb_width,$thumb_height,$jpg_quality; //Get the file extension! $file_ext=file_ext($file); //The GD Libary only supports jpg and gif really, well it can only make a gif a jpg. There are other ways like image magik, but not many have it so I didn't include that. So dent anything that isn't a gif or jpg . $Allow=array("jpg","gif","png"); If(in_array($file_ext,$Allow)) { //Lets do some converting! $imgdata=getimagesize($full_server.$album.$file); $imgresized=imagecreatetruecolor($thumb_width, $thumb_height); If($file_ext=="gif") { $imgsoruce=imagecreatefromgif($full_server.$album.$file); } Elseif($file_ext=="jpg") { $imgsoruce=imagecreatefromjpeg($full_server.$album.$file); } Elseif($file_ext=="png") { $imgsoruce=imagecreatefrompng($full_server.$album.$file); } Else { return false; } imagecopyresized($imgresized, $imgsoruce, 0, 0, 0, 0, $thumb_width, $thumb_height, $imgdata[0], $imgdata[1]); $new_file=$full_server.$album.$file_name."_thumb.".$file_ext; //PHP 4.4.X added safemode check which made me add this here.. $fh=fopen($new_file,'w'); fclose($fh); If($file_ext=="gif") { If(!imagegif($imgresized, $new_file)) { return false; } } Elseif($file_ext=="jpg") { If(!imagejpeg($imgresized, $new_file,$jpg_quality)) { return false; } } Elseif($file_ext=="png") { If(!imagepng($imgresized, $new_file)) { return false; } } imagedestroy($imgsoruce); imagedestroy($imgresized); return True; } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/ Share on other sites More sharing options...
printf Posted February 2, 2009 Share Posted February 2, 2009 What do you mean by faded, edges, center of image, whole image? Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/#findComment-752486 Share on other sites More sharing options...
dylanb Posted February 2, 2009 Author Share Posted February 2, 2009 hi, yes, i want to overlay the whole image to make it faded, the thumbs are always 15x15px, so the overlay image will be the same, maybe a tranparent png would be better for the overlay, then i could make edge effects too... Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/#findComment-752488 Share on other sites More sharing options...
printf Posted February 2, 2009 Share Posted February 2, 2009 Your better off using a mask then, especially when using GD. create predefined transpanet masks then over layer the mask on top of your image. That the best way to do it with GD because GD doesn't have the powerful layering options like imagemagick has. If you want example just tell me and I will give you one that will work with all the image types GD supports. For jpg(), the mask won't transparent, but you can set the fade in transparent color to match your background. Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/#findComment-752492 Share on other sites More sharing options...
dylanb Posted February 2, 2009 Author Share Posted February 2, 2009 I dont mind how its done, im just looking for an easy way to make the thumbnails faded, the kind of look you would get if you had a white layer over the top with say 25% tranparency. can you tell me how i might incorporate this into the code above, thanks Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/#findComment-752496 Share on other sites More sharing options...
.josh Posted February 2, 2009 Share Posted February 2, 2009 find a good watermark tutorial. Same principle. Just make an image in your image editor that's white with a transparency of whatever and use that as the watermark. Quote Link to comment https://forums.phpfreaks.com/topic/143454-image-overlay-with-gd/#findComment-752519 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.