That means you are actually not retrieving the picture directly, but have a script that retrieves the image and also draws text on it. You could of course make a http request from your server to your server, but that's really unnecessary, and I'd not recommend it.
Assuming your text drawing script is not contained within a function, you could
# initial code for emailing stuff...
...
# since it's your script, you should know what variables are needed by it.
# I'm just assuming what variables are needed... and proceed to set them up
$textToDraw = 'Merry Christmas';
$imageFile = '/images/house_with_snow.jpg';
$imageMaxWidth = 200;
$imageMaxHeight = 200;
# Now everything is ready for text drawing - just include script
require 'imageScript.php'
# And you should obviously not only know what vars are needed by imageScript.php,
# but also what vars are set up in it...
# Once again, I have to guess since it's not my script, and I'm guessing
$image; // really is an image resource now.
# rest of code for emailing stuff
...
However, it would make a lot more sense to wrap the image handling in a function.
imageScript.php
function drawText($file_or_gd_resource, $text, ...) {
return $imageResource;
}
emailScript.php
require 'imageScript.php';
$image = drawText('images/house_with_snow.jpg', 'Merry Christmas', $width, $height);
# rest of emailing stuff
As for the script that is used to draw text on images through your webserver, it will now draw text in the exact same way as your other script
$maxLength = 200;
$text = sanitizeInput($_POST['textToDraw'], 'string', 200);
$file = sanitizeInput($_POST['image'], 'imageFile', 'jpg');
require 'imageScript.php';
$image = drawText($file, $text);