Jump to content

Creating an Image in PHP: I need larger text!


ivoilic

Recommended Posts

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?  :confused:

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 );
?>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 -

 

Link to comment
Share on other sites

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 );
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.