Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > GD and E-mail

GD and E-mail
Thread Tools
Junior Member
Join Date: May 2003
Status: Offline
Reply With Quote
Feb 23, 2004, 01:40 PM
 
Hey all,

I'd like print text onto an image with GD, then e-mail that image, but I haven't figured out how to use the image created by GD. All I can do it output it to the browser. How do you make the image created by GD an actual image, that can be downloaded from the browser or e-mailed? Any ideas?

Thanks!
jon
www.jmarus.com - kicks by JM
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 23, 2004, 04:01 PM
 
Originally posted by jon31:
Hey all,

I'd like print text onto an image with GD, then e-mail that image, but I haven't figured out how to use the image created by GD. All I can do it output it to the browser. How do you make the image created by GD an actual image, that can be downloaded from the browser or e-mailed? Any ideas?

Thanks!
jon
There's one very small step, then you're sorted. Instead of piping the output to the browser, just pipe it to a file like so:

[php]
$image = imagecreatetruecolor($height,$width);

...do yer image thing...

imagejpeg($image,'/tmp/image.jpg',95);
[/php]

So now your manipulated image is sitting in the '/tmp' folder, ready for you to email it. Here's a simple script using the PEAR classes:-

[php]
require_once('Mail.php');
require_once('Mail/mime.php');

$content['html'] = "<p>Please find your image attached</p>";
$content['text'] = "Please find your image attached";

$mime = new Mail_mime("\n");
$mime->setTXTBody($content['text']);
$mime->setHTMLBody($content['html']);
$mime->addAttachment('/tmp/image.jpg','image/jpeg',null,true);

$body = $mime->get();
$headers = $mime->headers(array('From' => $from, 'Subject' => $subject));

$mail =& Mail::factory('mail');
$result = $mail->send("noone@nowhere.com",$headers,$body);

[/php]
Computer thez nohhh...
     
jon31  (op)
Junior Member
Join Date: May 2003
Status: Offline
Reply With Quote
Feb 23, 2004, 04:14 PM
 
Thanks Simon, that works perfectly!
www.jmarus.com - kicks by JM
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:01 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2