Re: image reduce or enlarge
| From: | (Richard Lynch) | Date: | Tue, 04 Jul 2000 02:38:04 +0000 |
| Subject: | Re: image reduce or enlarge | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4654@lists.php.net to get a copy of this message | ||
In article <0f6a01bfe442$5ec00440$34b3e6cd@perfekt.net>,
falco@perfekt.perfekt.net ("Chris W.") wrote:
> I have an idea for something that I would like to do but I do not know how
> to do it. My idea is to be able to download image from a web site and then
> be able to display it on my web site and either reduce the image or enlarge
> it. Everything seems to be nice but I would like to ask for any suggestions
> on how can I do it maybe? or if you know any places that they might have
> some examples
There is a "File Upload Feature" section on php.net to explain how to
upload images to your server.
If you want to snag an image from another server, just do this:
<?php
$source = fopen("http://someserver.com/image.jpg",
'r') or die("Could
not read remote image.");
$destination = fopen("/path/to/writable/dir/image.jpg", 'w') or
die("could not open local file");
while (!feof($source)){
$data = fread($source, 1000000);
fwrite($destination, $data);
}
?>
Then to scale it, you could get ImageMagic (aka "convert") on your server,
and do:
exec("/path/to/convert -scale .5 image.jpg > image2.jpg", $output, $error);
while (list(,$line) = each($output)){
echo $output, "<BR>\n";
}
if ($error){
echo "OS Error $error: Usually path/permissions problem.<BR>\n";
exit;
}
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)