Re: Serving an image

From: Date: Tue, 16 Oct 2012 16:42:56 +0000
Subject: Re: Serving an image
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-319482@lists.php.net to get a copy of this message
2012/10/15 viper <recursivepointer@gmail.com>: > On Mon, Oct 15, 2012 at 5:48 PM, Rick Dwyer <rpdwyer@earthlink.net> wrote: >> I am sending an email with a logo at the top of the email. The source of the image for the >> logo is: >> >> http://myurl.com/image.php?id=5 >> >> Image.php then calls a function that simply returns the following: >> >> >> >> $image='<img >> src="http://myurl.com/images/logo.jpg" />'; >> return $image; >> >> >> >> Calling the page directly via the URL >> http://myurl.com/image.php?id=5 works fine. >> But when the email is opened, I get the broken link/image icon even though I can see in my >> source that the URL which works when loaded into a browser. >> >> What needs to be done to serve that image to a email client when it is opened? > > in image.php you should return an image/xxx file and not an HTML tag. > try something like this: > > image.php: > > $im = imagecreatefrompng("test.png"); > header('Content-Type: image/png'); > imagepng($im); > imagedestroy($im); > > then in your email you can put: > <img src="http://myurl.com/image.php?id=5" /> > What is the diference between using imagecreatefrompng() and readfile()? Any performance improvement?

« previous php.general (#319482) next »