Re: Help please!
| From: | Richard Lynch | Date: | Tue, 02 Jul 2002 23:42:45 +0000 |
| Subject: | Re: Help please! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105090@lists.php.net to get a copy of this message | ||
>Hello,
> I have a PHP script which gets data from a MySQL database and
>returns an image. So <img src="getdata.php?id=3"> returns the image of
>id 3 from the database. What I really want is to state width is 100 and
>height is 100 for example so I do not have to downlaod the entire
>picture and specify the width and height as part of the image:
>
> Do not want
> <img src="getdata.php?id=3" width="100" height="100">
>
> WHat I want
> <img src="getdata.php?id=3&width=100&height=100">
>
> WHich will be a lot quicker on the client side.
>
> I cannot make a permanent file to use when I get the information
>from the PHP database due to server security, only a tmpfile which the
>data can then be placed. But to use the image functions you need to
>specify a filename. THere does not seem to be a way to get the filename
>of a file pointer so how do I do it please?
What *I* have found easiest is to store the image size with the filename in
the database.
So id=3 will also look up width/height.
You may be able to use getImageSize() to get the info you need.
NOTE:
The size of the image DOWNLOADED to the client remains the same. PERIOD.
Your scaling by 100 and 100 only does:
1. Scales the image on the CLIENT, after downloading the whole thing.
2. Tells the HTML layout how big a "hole" to leave until the image shows up.
It never, ever, improves actual bandwidth.
#2 *DOES* make the site 'seem' faster to the user, since they can read the
text while waiting for the image.
If your image is much larger than 100 x 100, and you are going to scale it
anyway, you should look into scaling it on the server long, long before that
HTML request comes in.
--
Like Music? http://l-i-e.com/artists.htm