Jump to content

problem with getimagesize


linus72982

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/206956-problem-with-getimagesize/
Share on other sites

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.

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?

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.