Jump to content
Sign in to follow this  
Matpatnik

[fixed]can't Make A Function With My Snippets

Recommended Posts

The code below works good alone so fare but I need to call it more then once.Copy and paste can't be the solution, I hope hehe!a soon as I wrap this snippets to create a function out of it it give me this error:

the image ... cannot be displayed, because it contain errors.
I tried to wrap only the foreach() as a function, same errorWhere ever I wrap it it give me the error.can someone give me a hand on this plz, Thank you.
$fontSize = 15;$ox = 10;$y = 40;$text = $row['description'];// Set the content-typeheader('Content-type: image/png');// Create the image$im = imagecreatetruecolor(750, 300);// Create some colors$beige = imagecolorallocate($im, 255, 206, 122);$dark_red = imagecolorallocate($im, 193, 0, 0);$grey = imagecolorallocate($im, 128, 128, 128);$black = imagecolorallocate($im, 0, 0, 0);imagefill($im, 0, 0, $beige);$text = text_to_array($text);foreach ($text as &$value){	$x = $ox;	foreach ($value as &$val)	{		$mod = 0;				if (substr($val, 0, 3) == '[B]')		{			$val = substr($val, 3);			$mod = 1;		} else if (substr($val, 0, 3) == '[I]')		{			$val = substr($val, 3);			$mod = 2;		} else if (substr($val, 0, 4) == '[BI]')		{			$val = substr($val, 4);			$mod = 3;		}		// Bounding box		$bbox = imagettfbbox($fontSize, 0, 'Fonts/'. $fonts['bkant'][$mod], $val);				imagettftext($im, $fontSize, 0, $x, $y, $black, 'Fonts/'. $fonts['bkant'][$mod], $val);		$x += $bbox[2] + 10;	}	$y += $bbox[1] + ($bbox[1] - $bbox[5]) + 5;}unset($val);unset($value);// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);imagedestroy($im);

Edited by Matpatnik

Share this post


Link to post
Share on other sites

I probably sent a wrong parameter somewhere ^^

Edited by Matpatnik

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...