Vivid Lust Posted May 23, 2009 Share Posted May 23, 2009 Is there anyway to do this without using getImageSize() ??? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/ Share on other sites More sharing options...
Yeodan Posted May 23, 2009 Share Posted May 23, 2009 html has an image resize tag Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840670 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 Oh, which keeps the original aspect ratio if there is a limit of 200px on the width? I don't think there is Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840671 Share on other sites More sharing options...
GingerRobot Posted May 23, 2009 Share Posted May 23, 2009 html has an image resize tag Which is almost certainly a bad way to do it. If you use a big image and "resize" it with the img tag's attributes, then it'll still use just as much bandwidth as the big image and still take just as long to load. Vivid Lust, why don't you want to use getImageSize()? Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840684 Share on other sites More sharing options...
Daniel0 Posted May 23, 2009 Share Posted May 23, 2009 Oh, which keeps the original aspect ratio if there is a limit of 200px on the width? I don't think there is Yes there is, you just set height = height * (200/originalWidth). It's basic mathematics. You find the relative growth of the width and multiply the height with that same growth rate. Doing that you'll retain the proportions. As GingerRobot said, you still shouldn't use HTML attributes for image resizing though. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840690 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 I don't know the original width/height, all this is coming out from the database I can't use getImageSize() , host has disabled allow_url_fopen Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840691 Share on other sites More sharing options...
Daniel0 Posted May 23, 2009 Share Posted May 23, 2009 Well, if you cannot get the image then you obviously cannot resize it either. Find a real host. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840692 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 e.g ? Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840694 Share on other sites More sharing options...
PFMaBiSmAd Posted May 23, 2009 Share Posted May 23, 2009 You should not be using a URL with getImageSize() when the file is on your own server and if the file is in a database and you are manipulating it using GD functions, you can get the size using other GD functions than getImageSize(). How are you using getImageSize()? What is your actual code? Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840695 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 Hi, I have image URL's stored in the database and want to resize them so they fit into the div width of X and so that they mantain their original aspect ratio. My first step would be: GetImageSize($image); where $image is the current URL from the database. However my host does not allow this. Jake. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840702 Share on other sites More sharing options...
Michdd Posted May 23, 2009 Share Posted May 23, 2009 If you figure out some way to get the original dimensions of the image you could use something like this to scale it down: function get_new_dimensions($image) { $size = getimagesize($image); list($width, $height) = $size; while($width > 130 || $height > 130) { $width *= .9; $height *= .9; } $new_size = array($width, $height); return $new_size; } Just change the 130's to the max width and height of the resized image. Edit: That's only to get the new dimensions, of course. Then you'd have to create a new image with those aspects. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840705 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 I've already said my host doesn't allow getimagesize() .. thanks for trying. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840707 Share on other sites More sharing options...
Daniel0 Posted May 23, 2009 Share Posted May 23, 2009 Find a real host. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840708 Share on other sites More sharing options...
Michdd Posted May 23, 2009 Share Posted May 23, 2009 I've already said my host doesn't allow getimagesize() .. thanks for trying. I was just saying that when you find a better host.. You might want to try http://000webhost.com I think they're one of the best free hosts. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840723 Share on other sites More sharing options...
Daniel0 Posted May 23, 2009 Share Posted May 23, 2009 Oh... that's why. Seriously, if you want proper hosting you'll have to pay for it. Ideally you would purchase a VPS so you have full control over its configuration and so other people's sites won't bring down your site as well. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840727 Share on other sites More sharing options...
Vivid Lust Posted May 23, 2009 Author Share Posted May 23, 2009 err I do pay for it thanks. Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-840753 Share on other sites More sharing options...
Vivid Lust Posted May 24, 2009 Author Share Posted May 24, 2009 Problem solved = friend gave my unmetered hosting for free:) Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-841215 Share on other sites More sharing options...
stelthius Posted May 24, 2009 Share Posted May 24, 2009 Not to sound like an ass but getting free "Unmetered" hosting isnt going to sovle your problem as Daniel said you will need seomthing that you can atleast control its configuration, E.G Vps Server personally i like my Dedi's but shared hosting is not going to pay off in the long run if another users site goes down for any reason you may suffer from that, so be smart and take a VPS atleast Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-841223 Share on other sites More sharing options...
Vivid Lust Posted May 24, 2009 Author Share Posted May 24, 2009 My friend has a VPS, this is on a VPS, so he can enable anything I want. Plus I'm getting this for free Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-841227 Share on other sites More sharing options...
stelthius Posted May 24, 2009 Share Posted May 24, 2009 You're missing the point, we mean a server "You" control not someone else but nvm if you're happy with second best enjoy it Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-841228 Share on other sites More sharing options...
Vivid Lust Posted May 24, 2009 Author Share Posted May 24, 2009 I'm only 16 and don't have a job, so .... Quote Link to comment https://forums.phpfreaks.com/topic/159377-resize-image-with-same-aspect-ratio/#findComment-841229 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.