linus72982 Posted July 7, 2010 Share Posted July 7, 2010 I'm stumped. I think this might have something to do with configuration but I get the following error: Warning: getimagesize(Resource id #2) [function.getimagesize]: failed to open stream: No such file or directory in D:\Hosting\5589581\html\imgSRC\test.php on line 5 on this code: $singleImgData = array(); $imgSize = array(); $useImg = imagecreatefrompng("genericav.png"); $imgSize = getimagesize($useImg); $id = 1; $x = 1; $y = 1; while ($id <= ($imgSize[0] * $imgSize[1])) { $singleImgData[$id] = imagecolorat($useImg,$x,$y); $id++; if ($x < $imgSize[0]) {$x++;} else { $y++; $x = 1; } } print_r($singleImgData); The picture is in the same directory and all that, not sure what I'm doing wrong or if it is just the config of the server. Excuse the unpolished code, I'm still learning. Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/ Share on other sites More sharing options...
TapeGun007 Posted July 7, 2010 Share Posted July 7, 2010 I assume something is wrong with the path since it simply cannot find the file. Quote Link to comment https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/#findComment-1082225 Share on other sites More sharing options...
linus72982 Posted July 7, 2010 Author Share Posted July 7, 2010 I don't see how it could be a problem with the path since the create file from png function above it doesn't spit an error. I've checked and re-checked and triple checked the name and type, spelling, made sure it was in the directory, everything. It's there, in the same folder as this file, exactly as spelled. I'm stumped. Quote Link to comment https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/#findComment-1082227 Share on other sites More sharing options...
PFMaBiSmAd Posted July 7, 2010 Share Posted July 7, 2010 If you read the documentation for the getimagesize() function, you will learn that it takes the filename as a parameter. It does not take the image resource produced by the imagecreatefrompng() function. Quote Link to comment https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/#findComment-1082228 Share on other sites More sharing options...
linus72982 Posted July 7, 2010 Author Share Posted July 7, 2010 Worked great, thanks! As a side question, now that it's working, I have a question about the output. The code I posted above (appended with the fix of course) outputs only 9899 values where it should, by my math, output 10,000 values. All the empty values are at the end. The image is 100px X 100px, I get the size in x and y, multiply the two to get the total number of px - why am I 100 pixels short? Of course it actually prints 10,000 variables, it just stops assigning readable values to the last 100 so that the end looks like [9900] => [9901] => [9902] => [9903] => There isn't a column of 0,0 and 0,1 and 0,2, etc that I'm missing is there? Perhaps 1,0 and 2,0, etc? Quote Link to comment https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/#findComment-1082237 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.