transferring another .jpg to your own
| From: | Anthony Ritter | Date: | Tue, 04 Mar 2003 23:19:59 +0000 |
| Subject: | transferring another .jpg to your own | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138188@lists.php.net to get a copy of this message | ||
Using PHP 4.1.1. / Apache / Win 98
I'd like to use a .jpg from another URL - say:
http://www.blah.com/foo.jpg
and turn it into a variable using PHP and then once it is a variable to try
to manipulate that image using GD Libraries which are installed.
Is this possible?
I tried placing the string of the URL into a variable like:
$theoldimage="http://www.blah.com/foo.jpg";
and then calling this function of:
$thenewimage=imagecreatefromjpeg ($theoldimage);
but it did not return a value when I echo'ed
$thenewimage
Many thanks for any advice.
Tony Ritter
..................................................................
function LoadJpeg ($imgname) {
$im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (150, 150); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}