ivoilic Posted February 26, 2012 Share Posted February 26, 2012 Hello Forums, So basically I am trying to place text over an image. It works but the max text size is 5 which is way too small for my needs! What can I do to increase the size of the text? If anyone can help it would be much appreciated. Here is my code: <?php $title = $_REQUEST['title'] ; $my_img = imagecreatefrompng ( "Template.png" ); $text_color = imagecolorallocate( $my_img, 0, 0, 0 ); imagestring( $my_img, 5, 30, 25, "$title", $text_colour ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $text_color ); imagedestroy( $my_img ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/ Share on other sites More sharing options...
ivoilic Posted February 26, 2012 Author Share Posted February 26, 2012 NVM Figured it out But I could also use some help with merging images! Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321533 Share on other sites More sharing options...
litebearer Posted February 26, 2012 Share Posted February 26, 2012 Whenever feasible, post your solution so that others with same type of issue may gain some insight Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321534 Share on other sites More sharing options...
ivoilic Posted February 27, 2012 Author Share Posted February 27, 2012 Thanks litebearer! Well I got my solution from a tutorial so I will just post a link to it. I just took the same code with some slight modifications to fit my specific needs. http://www.phpfreaks.com/tutorial/php-add-text-to-image If anyone can still help me with combining images it would be a huge help! Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321552 Share on other sites More sharing options...
blacknight Posted February 27, 2012 Share Posted February 27, 2012 http://php.net/manual/en/function.imagecopy.php Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321563 Share on other sites More sharing options...
ivoilic Posted February 27, 2012 Author Share Posted February 27, 2012 Thank you for the link blacknight, but that is not exactly what I was talking about. I am trying to set something up where a user could go to my site enter text and upload a picture which would then be combined with a background image. I have the text part down: $image = imagecreatefrompng ( "Templates/template.png" ); // Path to our font file $font = 'MJoa'; $italic = 'MJoaIta'; // pick color for the text $fontcolor = imagecolorallocate($image, 0, 0, 0); //Create Title imagettfbbox(35, 0, $font, $title); imagettftext($image, 35, 0, 40, 80, $fontcolor, $font, stripslashes($title)); What I need is some way of placing one image over another and then flattening it. Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321575 Share on other sites More sharing options...
litebearer Posted February 27, 2012 Share Posted February 27, 2012 essentially take image1, add text to create image2, take image2 and overlay it on image2 Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y. See blacknight's link - Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321576 Share on other sites More sharing options...
blacknight Posted February 27, 2012 Share Posted February 27, 2012 this is the function i use to combine images function combineImage( $image,$filename,$x_loc,$y_loc ) { $info = getimagesize($filename); switch( $info['mime'] ) { case 'image/jpeg' : $im_temp = @imagecreatefromjpeg($filename); break; case 'image/png' : $im_temp = @imagecreatefrompng($filename); break; case 'image/gif' : $im_temp = @imagecreatefromgif($filename); break; default: debugMode( $line,'Unhandled image type: ' . $info['mime'] ); } // Get the image dimentions $im_temp_width = imageSX( $im_temp ); $im_temp_height = imageSY( $im_temp ); // Copy created image into main image @imagecopy( $image,$im_temp,$x_loc,$y_loc,0,0,$im_temp_width,$im_temp_height ); // Destroy the temp image if( isset($im_temp) ) { @imageDestroy( $im_temp ); } } Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321577 Share on other sites More sharing options...
ivoilic Posted February 27, 2012 Author Share Posted February 27, 2012 Thank you both for your help I was literally just looking at http://www.php.net/manual/en/function.imagecopymerge.php It was the one under imagecopy. :) :) :) Quote Link to comment https://forums.phpfreaks.com/topic/257823-creating-an-image-in-php-i-need-larger-text/#findComment-1321580 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.