Jump to content

php & images


Ruth

Recommended Posts

i've got a script that will allow a user to enter text, select any image off their computer, and select a background. The idea is to make a postcard of sorts. I've got it working but it doesn't look very good. It just looks like one image was slapped onto another. Can anyone tell me how to get the users image to blend into the background so it looks like one image using php. Here is my code.

 

<?php

//get vars

$image_caption = $_POST['image_caption'];

$image_username = $_POST['image_username'];

$image_tempname = $_FILES['image_filename']['name'];

$today = date ("Y-m-d");

$destination = $_POST['destination'];

 

//upload image and check for image type

$ImageDir = "C:/projects/pratice/WWW/ch07/virtual_vacation/images/";

 

$ImageName = $ImageDir . $image_tempname;

 

//get to see if upload was successful

if (move_uploaded_file($_FILES['image_filename']['tmp_name'],$ImageName))

{

//get info about image being uploaded

list($width, $height, $type, $attr) = getimagesize($ImageName);

 

//check if img is jpg

if ($type <> 2)

{

echo "Sorry, but the file you uploaded was not a JPG file.<br />";

echo "Please hit your browsers back button and try again.";

}

else

{

//image is ok to proceed

$dstfilename = $ImageDir . $destination . ".jpg";

 

//blend 2 imgs

$image = imagecreatefromjpeg($ImageName);

list($width2, $height2, $type2, $attr2) = getimagesize($dstfilename);

 

$image2 = imagecreatefromjpeg($dstfilename);

imagecopymerge($image2, $image,50,140,0,0, $width, $height, 100);

 

}

 

if ($image_caption )

{

//add text on img

imagettftext($image2, 12,0,20,20,0, "arial.ttf", $image_caption);

}

 

header("Content-type:image/jpeg");

imagejpeg($image2);

}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/99395-php-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.