I have a script that uploads files uploaded through my website directly to my Amazon s3 bucket.
This never saves the file permanetly to my server, just as a temp_file_location
This works perfect alone.
However,
I am trying to now add a watermark to the image before passing the temp_file_location to the s3 function to upload.
My question is, how can I use the code below, with the temp_file and then return a new temp_file (which is the watermarked version)
Here is just the code for the watermarker, I need this to start with the temp_file and leave me with a new temp_file_location:
$temp_file_name = $_FILES['theFile']['tmp_name']; $image = $temp_file_name; // creating png image of watermark $watermark = imagecreatefrompng('watermark.png'); // getting dimensions of watermark image $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // creting jpg from original image $image = imagecreatefromjpeg($temp_file_name); //something went wrong if ($image === false) { return false; } // getting the dimensions of original image $size = getimagesize($image_path); // placing the watermark 5px from bottom and right $dest_x = $size[0] - $watermark_width - 10; $dest_y = $size[1] - $watermark_height - 10; // blending the images together imagealphablending($image, true); imagealphablending($watermark, true); // creating the new image imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); //HERE I NEED A $temp_file_name TO BE THE UPDATED FILE WITH THE WATERMARK TO PASS TO THE S3 FUNCTION. // destroying and freeing memory imagedestroy($image); imagedestroy($watermark);
Any ideas??
Thanks ahead!!