Jump to content

Adjust Image Size To Fit Page


ProblemHelpPlease
 Share

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);

Edited by ProblemHelpPlease
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...