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..

 

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
https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068028
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
https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068238
Share on other sites

Archived

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

×
×
  • 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.