onenonly Posted July 31, 2009 Share Posted July 31, 2009 getimagesize() function is too slow when loading . all i want is image height and width but it takes so long I have 5 image on my page, each is like 322 kb it lags for like 3 secs but thats way to long for just 5 image soon i will be adding thousands of image anyways of getting image width and height faster? Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/ Share on other sites More sharing options...
TeNDoLLA Posted July 31, 2009 Share Posted July 31, 2009 How exactly you use the getimagesize? Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887311 Share on other sites More sharing options...
onenonly Posted July 31, 2009 Author Share Posted July 31, 2009 Im using a remote file which is 322kb total of five on 1 page i get the width and height from my remote image using getimagesize() then resize the image them Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887329 Share on other sites More sharing options...
lonewolf217 Posted July 31, 2009 Share Posted July 31, 2009 well, why exactly do you have to resize the images automatically ? perhaps there is a better way. are you trying to fit them in a predetermined area ? Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887332 Share on other sites More sharing options...
TeNDoLLA Posted July 31, 2009 Share Posted July 31, 2009 Most likely reason to the slowness is that your are dealing with remote content and when you call imagesize for a remote image php will download the image first to your server. Maybe try to use cURL instead. See this and the first comment from the comments: http://fi2.php.net/function.getimagesize . I haven't used curl so I can't really help with that. Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887345 Share on other sites More sharing options...
dreamwest Posted July 31, 2009 Share Posted July 31, 2009 function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887348 Share on other sites More sharing options...
.josh Posted July 31, 2009 Share Posted July 31, 2009 As tendolla mention, I don't think it is the function causing the lag, but images being downloaded causing lag. Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887351 Share on other sites More sharing options...
dadamssg Posted July 31, 2009 Share Posted July 31, 2009 you could always create a new db table and write a script to store the info there when you upload them... Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887374 Share on other sites More sharing options...
Q Posted July 31, 2009 Share Posted July 31, 2009 you could always create a new db table and write a script to store the info there when you upload them... Or at least make the loading page insert the info for the images on loading, this will make sure you would never have to get the size of any image more than once.. Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887504 Share on other sites More sharing options...
TeNDoLLA Posted July 31, 2009 Share Posted July 31, 2009 Indeed some sort of cache or storage for image information could be a choice also. So that you wouldn't need to get the sizes everytime someone loads images. Quote Link to comment https://forums.phpfreaks.com/topic/168223-better-way-to-get-image-width-hieght/#findComment-887507 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.