Jump to content

edit image


the-botman

Recommended Posts

ok hi guys...

 

i have a script on my site and what it does is they users pic an image they want to add their name to and then add the name and download the image with the name on it.. now i want to make it such they can upload their own image and add text to it can someone giv me an idea on how to do this.

Link to comment
https://forums.phpfreaks.com/topic/200634-edit-image/
Share on other sites

ok hi guys..

 

i have th script, what it does is gives the user an option to upload their image/walpaper/photo and add a fame to it then they can download it with the frame, now i want it to work a bit diff.. i want it to give them the option to upload the pic then select if they want to add a frame they click yes and if they want to add text to it they can enter it in a box then click save and get an option to download it ... this is the codes

form.php

<form action="upload.php"  enctype="multipart/form-data"
method="post">
  <p>Select a file: 
    <input type="file" name="user_file" size="50">
      <input type="submit" name="submit" value="Upload Now" />
</p>
</form>

uploa.php

<center>
<?
$name=$_FILES['user_file']['name'];
$time=time();
$userimage="images/".$name;
$usertype=$_FILES['user_file']['type'];

if(ereg("jpeg",$usertype))
		$userimage="images/".$time.".jpg";


if (ereg("jpeg",$usertype))
{	
$move=move_uploaded_file($_FILES['user_file']['tmp_name'],$userimage);

echo "congratulation your image was uploaded <br>
now you can choose any frame to apply it <br><br> ";


echo "<a href='frame.php?border=120
&selected=frames/33.jpg
&userimage=$userimage
&type=$usertype'>
<img src='frames/33.jpg' width='300'></img></a>"; 

echo"<br><br><hr><br>";

echo"<a href='frame.php?border=70&selected=frames/22.jpg &userimage=$userimage&type=$usertype'><img src='frames/22.jpg' width='300'></img></a>";

echo"<br><br><hr><br>";

echo"<a href='frame.php?border=90&selected=frames/101.jpg &userimage=$userimage&type=$usertype'><img src='frames/101.jpg' width='300'></img></a>";

echo"<br><br><hr><br>";

echo"<a href='frame.php?border=80&selected=frames/100.jpg &userimage=$userimage&type=$usertype'><img src='frames/100.jpg' width='300'></img></a>";
               
}

else
{
echo "we dont support this type";
}

?>
</center>]

frame.php

<?
$selected=$_GET['selected'];
$border=$_GET['border'];
$userimage=$_GET['userimage'];
$usertype=$_GET['type'];


if (ereg("jpeg", $usertype))
{

$info=getimagesize($userimage);
$width=$info[0];
$height=$info[1];

$frameinfo=getimagesize($selected);
$framewidth=$frameinfo[0];
$frameheight=$frameinfo[1];

//the mathematical relation between  border size
//and frame width//
$percentwidth=$border/$framewidth;
$percentwidth+=$percentwidth/3.5;

// the mathematical relation between border size
// and frame height
$percentheight=$border/$frameheight;
$percentheight+=$percentheight/4;


//the width of the frame that must be 
//to fit the user image
$width2=$width+($width*$percentwidth);

//the height of the frame that must be 
//to fit the user image
$height2=$height +($height*$percentheight);

$src=imagecreatefromjpeg($selected);
$dist=imagecreatetruecolor($width2, $height2);
imagecopyresized($dist,$src,0,0,0,0,$width2,                $height2,$framewidth,$frameheight);

$usersrc=imagecreatefromjpeg($userimage);

// we divide by 2 because the frame consists from
//2 boundaries(or 2 border)
$x=($width*$percentwidth)/2;
$y=($height*$percentheight)/2;

imagecopymerge($dist,$usersrc,$x,$y,0,0,$width,                                   $height,100);

imagejpeg($dist,$userimage);

echo "<h2>congratulation::</h2> Your image was edited rt click and choose save Picture as<br><br>";			

echo"<img src=$userimage></img>";											
}


?>

 

thanks in advance

The Btman

 

Link to comment
https://forums.phpfreaks.com/topic/200634-edit-image/#findComment-1053183
Share on other sites

ok i have removed the frames from it and made it 2 pages just upload and add text but it uploads fine just wont add the text please check my code here it is

<?php  
session_start(); 
$_SESSION['name'] = $_POST['name'];

   $ShowBookmark = "False";
   include 'Include/Header.php'; 
        
if(isset($_POST['name'])) {  
    echo '<div class="hd2"><center><font color=#666666><strong>image Generator</strong></font></center></div><br>'."\n";        
    echo "<img src=\"upload.php?name={$_POST['name']}&number={$_POST['number']}\" /><br>";
    echo '<font face="Verdana" size="2"><a href="upload.php?name='. rawurlencode($_POST['name']) .'&number='. intval($_POST['number']) .'">Download Now!</a></font>';
    echo '<font face="Verdana" size="2"><center>'.$GLOBALS["Advert03"].'</center></font>'."\n";
    echo '<table id="" border="0" style="font-size:9pt;width:100%;">'."\n";
    echo '	<tr style="font-color:#85859c;"><td style="width:10px;"><img src="http://bhawap.com/Images/Logos/Logo_Back.gif"></td><td>'."\n";
    echo '		<font face="Verdana" size="2"><b><a href="process.php">Back</b></font></a><br>'."\n";
    echo '	</td></tr>'."\n";
    echo '</table>'."\n";
    echo '<div class="hd5a">';
    echo '<div style="display: -wap-marquee; -wap-marquee-loop: 100; font-size: 8pt; color:#666;">More Soccer Kits Coming Soon</div></div>';

}

else {         
    Show_Form(); 
}


function Show_Form() {
    echo '<div class="hd2"><center><font color=#666666><strong>Personal Wallpaper Generator</strong></font></center></div><br>'."\n";
    echo '<form action="upload.php"  enctype="multipart/form-data" method="post">'."\n";
    echo '  Name: <input type="text" name="name" /><br>'."\n";             
    echo '                  </select>';       
    echo ' <p>Select an Image: '."\n";
    echo '  <input type="file" name="user_file" size="20">'."\n";
    echo '     <input type="submit" name="submit" value="Upload Now" />'."\n";
    echo '</p>'."\n";
    echo '</form> '."\n";
    echo '<font face="Verdana" size="2"><center>'.$GLOBALS["Advert03"].'</center></font>'."\n";
    echo '<table id="" border="0" style="font-size:9pt;width:100%;">'."\n";
    echo '	<tr style="font-color:#85859c;"><td style="width:10px;"><img src="http://bhawap.com/Images/Logos/Logo_Back.gif"></td><td>'."\n";
    echo '		<font face="Verdana" size="2"><b><a href="process.php">Back</b></font></a><br>'."\n";
    echo '	</td></tr>'."\n";
    echo '</table>'."\n";
    echo '<div class="hd5a">';
    echo '<div style="display: -wap-marquee; -wap-marquee-loop: 100; font-size: 8pt; color:#666;">More downloads coming soon</div></div>';
}

include 'Include/Footer.php';
Log_Hit("soccerkitgen"); 

?>

and the upload.php

<?php  

session_start();
if(isset($_SESSION['name'])) {    
      $name1 = $_SESSION['name'];
      $name1 = strtoupper($name1);
}
       


$name=$_FILES['user_file']['name'];
$time=time();
$userimage="images/".$name;
$usertype=$_FILES['user_file']['type'];

if(ereg("jpeg",$usertype)) {
		$userimage="images/".$time.".jpg";
}			

if (ereg("jpeg",$usertype))
{	
$move=move_uploaded_file($_FILES['user_file']['tmp_name'],$userimage);

}
header("Content-Type: image/jpg"); 
header('content-disposition: attachment; filename=".$time.".jpg); 

      $im = imagecreatefrompng($userimage'.jpg');
if(!$im){ 
  die("IMAGE CREATION FAILED");
}
      $white = ImageColorAllocate($im, 160, 139, 178);
      $boundsxx = imagettfbbox(12, 0, 'abid.ttf', $_SESSION['name']);
      $start_xx = 170 / 2 - ($boundsxx[2] - $boundsxx[0]) / 2;
      $start_yy = 57; 

Imagettftext($im, 12, 0, $start_xx, $start_yy, $white, 'abid.ttf', $name1);


  imagepng($im);
  ImageDestroy($im); 



?>

Link to comment
https://forums.phpfreaks.com/topic/200634-edit-image/#findComment-1053355
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.