Jump to content

Adjust Image Size To Fit Page


ProblemHelpPlease

Recommended Posts

I need to check the size of a remote image and adjust the width and height html tags if it is too big before the page loads. I have looked at using getimagesize in php but this doesnt work on a remote image as I have allow_url_fopen=off due to recent security problems.Does anyone have any ideas of another way to do this?

Link to comment
Share on other sites

Solution I have works ok but I have a question about image types. I am using the piece of code below and it seems to work fine for all jpg gif and png but should I be using the imagejpg command when the image is an unknown image from a remote server that maybe jpg gif or png.

imagejpeg($new_image, $tempfile,100);

Link to comment
Share on other sites

I could determine what the file extensions was but as it appears to work with any extensions I wonder if I need to bother. I am creating a temporary file on my server from the file on the remote server purley to gain width and height of the remote image. I don't actually display the created image, I display the remote one with the height and width tags set to the relevant size.

Link to comment
Share on other sites

If you're using CURL to just read the file's data and you have that in a string, you can get the dimensions like this without needing to write a new file:$image = imagecreatefromstring($curl_data);$w = imagesx($image);$h = imagesy($image);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...