Jump to content

[SOLVED] Working with External Images


Gafaddict

Recommended Posts

Hi guys,

 

At the moment I'm writing a script which deals with the possibility of analyzing a file that is not on my server -- rather, it is located on another server and a completely different domain. Say the image is http://www.example.com/logo.jpg.

 

The script needs to find out the dimensions of logo.jpg when a user inputs that string into a textbox. I know how to get the dimensions of an image on the server, but how would I get the dimensions of an external image? Is it even possible?

 

If that is not possible, how would one go about copying that external image from the URL to their own server? I've seen this done before in phpBB before but they don't seem to have any documentation about it.

 

Thanks in advance,

Link to comment
Share on other sites

same way as any other image...

<?php
$path= "http://www.example.com/logo.jpg";
$size = getimagesize($path);
//or even
$path = urlencode($path);
$size = getimagesize($path);
?>

 

EDIT:

also you can use copy to copy the image or imagecreatefromjpeg, providing fopen wrappers have been enabled

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.