plznty Posted January 26, 2010 Share Posted January 26, 2010 I want a picture to be shown withing another picture, the picture would have to be retrieved from a url. For example PICTURE.PHP - A 100x100 black box $url = file_get_contents("http://whereis.the/file/40x40.txt"); I want the url from $url to display within picture.php Could anyone give me some helpful links etc thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/ Share on other sites More sharing options...
MadTechie Posted January 26, 2010 Share Posted January 26, 2010 That's nice to know thanks.. Here is my Santa list: I'll like to be paid more and have more time off and a bigger.. wallet! EDIT: ahh a question, okay do you want to add text to the picture ? (as you opening a text file ?) if so look at imagettftext as for image on/in image imagecopymerge ie // Create image instances $dest = imagecreatefromgif('php.gif'); $src = imagecreatefromgif('php.gif'); // Copy and merge imagecopymerge($dest, $src, 10, 10, 0, 0, 100, 47, 75); // Output and free from memory header('Content-Type: image/gif'); imagegif($dest); imagedestroy($dest); imagedestroy($src); Quote Link to comment https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/#findComment-1001763 Share on other sites More sharing options...
plznty Posted January 26, 2010 Author Share Posted January 26, 2010 I was hoping to achieve that the main picture has a little picture at the top which the img url is gathered from $url, then to have text below. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/#findComment-1001765 Share on other sites More sharing options...
MadTechie Posted January 26, 2010 Share Posted January 26, 2010 okay I have created a sample, that you will probably need to tweak, but it should get to started <?php $filename = "White-Cat.jpg"; $width = 100; $height = 100; list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Create image instances $src = imagecreatefromjpeg($filename); $dest = imagecreatetruecolor($width+20, $height+40); // Resample imagecopyresampled($dest, $src, 10, 10, 0, 0, $width, $height, $width_orig, $height_orig); //text $black = imagecolorallocate($dest, 0xFF, 0xFF, 0xFF); $font_file = 'arial.ttf'; //text Data //$url = file_get_contents("http://whereis.the/file/40x40.txt"); $url = "PHP Freaks"; imagefttext($dest, 10, 0, 13, $height+30, $black, $font_file, $url); // Output and free from memory header('Content-Type: image/jpeg'); imagejpeg($dest); imagedestroy($dest); imagedestroy($src); [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/#findComment-1001775 Share on other sites More sharing options...
plznty Posted January 26, 2010 Author Share Posted January 26, 2010 You have gave me exactly what i asked for thanks saved me alot of time and hassle!! Quote Link to comment https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/#findComment-1001809 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.