Gaylen wrote:

> Check the validity of the link.

This is inherent to the process -- no need to worry - you just have to include
some error fallback code in the process.

> Check the size.  If less than a particular size, then PHP will
> resize/resample it and display a stndard Avatar sized icon.
> If too large, then disallow it.

Ok, seems like I've got it right.

> Can this be done without having to d/l the picture first?

Obviously not -- how could you possibly resize an image you don't have?!

> Can the Windoze
> PHP implementation handle it, as well as the *nix?

Yes, but if you intend to run the same code for both you'll have to either make
sure you have gd installed on both or that you run distinct programs for
resizing based on the OS.

So, what you have to code is:
1. Send a HTTP request to the server the user is pointing to in order to
retrieve the image;
2. Retrieve the image;
3. Check the image size;
4. Resample the image;
5. Store the image in a database/directory;
6. Display the image.

Technical details:
You'll have to separate the link the user passes in two parts: the server and
the path within the server. I suggest using function parse_URL (under "URL
Functions" in the manual) for this job.

Then you'll have to send the actual request. You should use a piece of code
similar to the one below for this job:
function getImageFile($host,$file)
  $request="GET $file HTTP/1.0\r\n"; // This is the path part of the link
  $request.="Host=$host\r\n\r\n"; // This is the server part of the link

  // Now let's try connecting:
  $fp=fsockopen($host, 80, $errno, $errstr, 30);

  // Let's see if we made it
  if (!$fp)
    // If we made it, let's send the request:
    fputs($fp, $request);

    while (!feof($fp))
      $response.=fgets($fp, 128);

So, we've solved point (2) in the process -- we now have the image file! All you
have to check the size of the string returned by this function, store it,
resample the image if needed and display it.

Let me know if I can be of further assistance.


PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to