Jump to content


Editing database Image

  • Please log in to reply
2 replies to this topic

#1 rav

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 August 2006 - 08:02 PM

I need to open an image from database to edit...

and witre text on it with php functions (text is being sent from a form on edit page)
and then I need it to be saved with different name in database...

I am not able to get image data and not sure how to get it???--(Currently, I am passing data with varables(they hold values of type, size, name, and image) in edit page to this process page)

Can any one help me in this please??
I will appreciate your help..
thank you
function ImageStringWrap($image, $font, $x, $y, $text, $color, $Text_Size, $maxwidth, $height, $subWidth, $subHeight, $align) 
$fontwidth = imagefontwidth($Text_Size); 
$fontheight = imagefontheight($Text_Size); 
$maxlines = floor($height /$fontheight)-$subHeight; 
if ($maxwidth != NULL) 
$maxcharsperline = floor($maxwidth/ $fontwidth) -$subWidth ; 
for ($i=0; $i < sizeof($text); $i++) 
$Text_Box_Size = imagettfbbox($Text_Size, 0, $font, "MXQJPmxqjp123"); 
$Text_Box_Width = abs($Text_Box_Size[2]) + abs($Text_Box_Size[0]); 
$Text_Box_Height = abs($Text_Box_Size[7] + $Text_Box_Size[1]); 
$Text_Height = $Text_Height + $Text_Box_Height; 

if ($align="l") 
$posx = $x; 
$posy = $y; 

$text = wordwrap($text, $maxcharsperline, "\n", 1); 
$lines = explode("\n", $text); 

foreach($lines as $lines) 
imagettftext($image, $Text_Size, 0, $posx, $posy, $color, $font, $lines); 
$posy+= $fontheight+10; 
//$y += $fontheight +10; 




header("Content-type: image/png"); 
$id = $_POST['id']; 
$desc= $_POST['desc']; 

$name= $_POST['name']; 
$image= $_REQUEST['image']; 
$type= $_REQUEST['type']; 
$size= $_REQUEST['size']; 

$subWidth = $_POST['subWidth']; 
$subHeight = $_POST['subHeight']; 

$font = $_POST['font1'];//'font/arial.ttf'; 



include 'config1.php'; 
include 'opendb.php'; 

$im= imagecreatefrompng($image); 

$textcolor = imagecolorallocate($im, $r, $g, $b); 


$imHeight = imagesy($im); 

ImageStringWrap($im, $font, $x, $y, $desc, $textcolor, $fontsize, $imWide, $imHeight,$subWidth, $subHeight,"l" ); 

imageSaveAlpha($im, true); 
ImageAlphaBlending($im, false); 

$outfile= "${id}.png"; 
imagepng ($im, $outfile); 
$size1 = filesize($im); 


$fp1 = fopen($outfile, 'r'); 
$content1 = fread($fp1, filesize($outfile)); 
$content1 = addslashes($content1); 

$size1 = filesize($outfile); 

$query = ("update imgtable set image1 = '$content1', type1 = '$type', size1 = '$size1', name1 = '$tgtFile', description = '$desc', x='$x', y='$y', font='$font', fontsize='$fontsize', r='$r', g='$g', b='$b', subWidth='$subWidth', subHeight='$subHeight', xLocPg='$xLocPg', yLocPg='$yLocPg' where id='$id'")or die("Couldn't update query, the ID was '$pid'<br>\n".mysql_error()); 

mysql_query($query) or die('Error, query failed'); 
$id= mysql_insert_id(); 
echo " <div align='center'>You have successfully added the Image! <a href='stickyView.php'>Click here to view</a></div>"; 



echo "<div align='center'>Please enter full record. <a href='stickyView.php'>Click here to Enter</a></div>"; 
echo "<br> $maxlines"; 


#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 August 2006 - 08:07 PM

Post ONCE in the most appropriate forum. Don't spam us. Your other posts will be deleted.

And to make your code readable, wrap code tags around, please.
Legend has it that reading the manual never killed anyone.
My site

#3 rav

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 August 2006 - 08:15 PM

i have put code tag aroung the code.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users