3raser Posted June 4, 2010 Share Posted June 4, 2010 Is their a way, on my image uploading script, to set a maximum width? Not height, just width. Because on my page, the picture will keep sticking out if it's width is greater than the box it's in. Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/ Share on other sites More sharing options...
mraza Posted June 5, 2010 Share Posted June 5, 2010 not clear, can you show your image code? if you are looking for image width then why not try to set in img tag? like <img src="" width="" height="" /> Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068018 Share on other sites More sharing options...
SharkBait Posted June 5, 2010 Share Posted June 5, 2010 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.. Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068023 Share on other sites More sharing options...
3raser Posted June 5, 2010 Author Share Posted June 5, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068028 Share on other sites More sharing options...
3raser Posted June 5, 2010 Author Share Posted June 5, 2010 Bump Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068039 Share on other sites More sharing options...
Alex Posted June 5, 2010 Share Posted June 5, 2010 How would I do that? Is getimagesize() only for width? . Read the documentation and find out. Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068040 Share on other sites More sharing options...
SharkBait Posted June 5, 2010 Share Posted June 5, 2010 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/203921-max-image-width/#findComment-1068238 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.