Jump to content

add frames to images


the-botman

Recommended Posts

ok hi guys..

 

i have made this code what it does it lets the user upload a pic then select a frame and it adds the frame to it then they can download now my issue is the pic does not fit right in some of the frames is there a way around this i will post my code here and u can tell meif u need to see the fames thanks here are the codes

form.php

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

   $ShowBookmark = "False";
   include 'Include/Header.php'; 
        
    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("imagegen"); 

?>

upload.php

<?php  
session_start();
if(isset($_SESSION['name'])) {    
      $name1 = $_SESSION['name'];
      $name1 = strtoupper($name1);
}
   $ShowBookmark = "False";
   include 'Include/Header.php'; 
       


$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/1.jpg&userimage=$userimage&type=$usertype&name=$name1'><img src='frames/1.jpg' width='300'></img></a>"; 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

echo"<a href='frame.php?border=120&selected=frames/14.jpg&userimage=$userimage&type=$usertype&name=$name1'><img src='frames/14.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>";											
}


?>

thnks in advance also i would like to know how to make the images showas small tumbnails for the user to chose from

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/200766-add-frames-to-images/
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.