I am trying to save the entire merged image but so far I can only manage to get the code below to save the uploaded image. Any help would be greatly appreciated.
PHP Code:<?php
include("config.php");
// Make sure an image is uploaded //
if ($uploadfile == ""){ die("please upload a pic"); }
/* TEST File Checking */
if($HTTP_POST_FILES['uploadfile']['size'] > 10000000000000000){
die("Image To Big!");
}
// Image extension check
$file_name = $HTTP_POST_FILES['uploadfile']['name'];
$file_ext = strtolower(substr($file_name, strrpos($file_name, ".")));
if ($file_ext != ".jpeg" AND $file_ext != ".jpg") {
die("Please use only JPG or JPEG files.");
}
// This is the temporary file created by PHP
$uploadedfile = $HTTP_POST_FILES['uploadfile']['tmp_name'];
// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);
$newwidth=156;
$newheight=84;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = "photos/". $HTTP_POST_FILES['uploadfile']['name'];
imagejpeg($tmp,$filename,100);
// Create image instances
$dest = imagecreatefromjpeg('image.jpg');
$src = imagecreatefromjpeg("photos/".$HTTP_POST_FILES['uploadfile']['name']);
// Copy and merge
imagecopymerge($dest, $src, 236, 148, 0, 0, 156, 84, 100);
// Rename Image here
$newname = rand(1,9999999);
rename("photos/".$HTTP_POST_FILES['uploadfile']['name'], "photos/$newname$file_ext");
// Output and free free from memory
//header("Content-Disposition: attachment; filename=image$file_ext");
//header("Pragma: no-cache");
//header('Content-Type: image/jpeg');
//imagejpeg($dest);
//imagedestroy($dest);
//imagedestroy($src);
// Remove the uploaded Pic from the server
//unlink("photos/".$HTTP_POST_FILES['uploadfile']['name']);
?>







Bookmarks