problems using simple functions from the gd library

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
newuser56
Forum Newbie
Posts: 2
Joined: Fri Jun 24, 2011 1:12 pm

problems using simple functions from the gd library

Post by newuser56 »

Hey I've just started using the gd library but I just can't get it to work. What I'm trying to do here is open a .png file a read the color of it's pixels.

Here the code:

Code: Select all

<?php

error_reporting(E_ALL);
$im = imagecreatefrompng("image.png");

if (!$im)
	die("error!");

for ($i = 0; $i < 20; $i++)
{
	for ($j = 0; j < 10; $j++)
	{
		if (imagecolorat($im, $i, $j) != 0)
		{
			echo "$i $j\n";
		}
	}
}

imagedestroy($im);

?>
Nothing happens here, but I know that $im is not null, so something is working.

Can you guys help me out?
newuser56
Forum Newbie
Posts: 2
Joined: Fri Jun 24, 2011 1:12 pm

Re: problems using simple functions from the gd library

Post by newuser56 »

lol nevermind.... there was an error in the for loop
Post Reply