Jump to content

Max image width


3raser

Recommended Posts

Do you want to resize the photo to a maximum width if it is beyond it?

 

On the file upload you can do a getimagesize() of the temp file that is uploaded to see if it's width is greater than the maximum you want too..

Link to comment
Share on other sites

Do you want to resize the photo to a maximum width if it is beyond it?

 

On the file upload you can do a getimagesize() of the temp file that is uploaded to see if it's width is greater than the maximum you want too..

 

Yes, I want it so if the image >WIDTH< is bigger than the maximum dems, I want it to be resized. But I don't know how to get the width.

 

How would I do that? Is getimagesize() only for width?

Link to comment
Share on other sites

<?php
$file = 'somelocation/the/new/file/goes/to.jpg';
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file) {
   // file has been move successfully
   $size = getimagesize($file);   // Width is first, Height is second and third argument is HTML for both
   if($size[0] > '1024') {
       // resize the photo
   } else {
       // Photo doesn't need to be resized.. continue
   }
}
?>

 

Is the roughly the idea :)

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.