# Stupid image functions

**URL:** <https://forum.kirupa.com/t/stupid-image-functions/24203>\
**Category:** Uncategorized\
**Created:** [June 27, 2003, 4:47am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203 "2003-06-27T04:47:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jubba](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@Jubba](https://forum.kirupa.com/u/Jubba)\
**Post date:** [June 27, 2003, 4:47am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/1 "2003-06-27T04:47:40Z")

</div>

Might as well post this question here as well… someone may learn something… I’m have a bit of trouble with the PHP image functions. The code is running correctly, but it doesnt’ show up as clearly as I would like it to…I’m trying to draw a J on the image. Here is the code:

```php
<?
header("Content-type: image/jpeg");

$j_zero = array("1", "1", "1", "1", "1", "1", "1", "1", "1", "1");
$j_one = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_two = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_three = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_four = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_five = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_six = array("1", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_seven = array("1", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_eight = array("1", "0", "0", "0", "0", "0", "0", "0", "0", "1");
$j_nine = array("0", "1", "1", "1", "1", "1", "1", "1", "1", "0");
$letterJ = array($j_zero, $j_one, $j_two, $j_three, $j_four, $j_five, $j_six, $j_seven, $j_eight, $j_nine);

$im = ImageCreate(100, 20);

ImageColorAllocate($im, 255,0,0);

$x_start = 20;
$y_start = 5;

for($i=0;$i<sizeof($letterJ);$i++)
{
	for($j=0;$j<sizeof($letterJ[0]);$j++)
	{
		if($letterJ[$i][$j] == 1)
		{
			ImageSetPixel($im, $x_start+$j, $y_start+$i, 255255255);
		}
	}
}

ImageJPEG($im);
ImageDestroy($im);
?>

```

but this is what it gets me: [http://www.bluefinatlantic.com/egTest/imageFunc/random/random2.php](http://www.bluefinatlantic.com/egTest/imageFunc/random/random2.php)

and thats not exactly clear now is it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 4:58am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/2 "2003-06-27T04:58:30Z")

</div>

if you printscreen it and zoom-in in paintbrush, you’ll see that the lines that it’s drawing are 1px wide each… if you make them wider (double the 1’s in the array) it should be much clearer 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:12am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/3 "2003-06-27T05:12:03Z")

</div>

actually I figured out the problem. It was becuase I was outputting as a jpg. A png, or a gif would be much clearer:) Now I just have to get my stupid function to work and I’ll be all set 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:18am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/4 "2003-06-27T05:18:09Z")

</div>

lol… im very interested in seeing the results :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:20am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/5 "2003-06-27T05:20:02Z")

</div>

here is what I have so far!

![](http://www.bluefinatlantic.com/egTest/imageFunc/random/random2.php)

the code is here (but its messy):

```php
<?
# Define Content
header("Content-type: image/png");

$im = ImageCreate(100, 20);
ImageColorAllocate($im, 255,0,0);

# Creates the "J"
$j_zero = array("0", "0", "1", "1", "1", "1", "1", "1", "1", "1");
$j_one = array("0", "0", "1", "1", "1", "1", "1", "1", "1", "1");
$j_two = array("0", "0", "0", "0", "0", "0", "0", "0", "1", "1");
$j_three = array("0", "0", "0", "0", "0", "0", "0", "0", "1", "1");
$j_four = array("0", "0", "0", "0", "0", "0", "0", "0", "1", "1");
$j_five = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$j_six = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$j_seven = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$j_eight = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$j_nine = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$letterJ = array($j_zero, $j_one, $j_two, $j_three, $j_four, $j_five, $j_six, $j_seven, $j_eight, $j_nine);

# Creates the "U"
$u_zero = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_one = array("1", "1", "0", "00", "0", "0", "0", "0", "1", "1");
$u_two = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_three = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_four = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_five = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_six = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_seven = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$u_eight = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$u_nine = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$letterU = array($u_zero, $u_one, $u_two, $u_three, $u_four, $u_five, $u_six, $u_seven, $u_eight, $u_nine);

# Creates the "B"
$b_zero = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$b_one = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$b_two = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$b_three = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$b_four = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$b_five = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$b_six = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$b_seven = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$b_eight = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$b_nine = array("1", "1", "1", "1", "1", "1", "1", "1", "0", "0");
$letterB = array($b_zero, $b_one, $b_two, $b_three, $b_four, $b_five, $b_six, $b_seven, $b_eight, $b_nine);

# Creates the "A"
$a_zero = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$a_one = array("0", "0", "1", "1", "1", "1", "1", "1", "0", "0");
$a_two = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$a_three = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$a_four = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$a_five = array("1", "1", "1", "1", "1", "1", "1", "0", "1", "1");
$a_six = array("1", "1", "1", "1", "1", "1", "0", "0", "1", "1");
$a_seven = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$a_eight = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$a_nine = array("1", "1", "0", "0", "0", "0", "0", "0", "1", "1");
$letterA = array($a_zero, $a_one, $a_two, $a_three, $a_four, $a_five, $a_six, $a_seven, $a_eight, $a_nine);

$color = 255255255;
$x_start = 20;
$y_start = 5;
# Function to display pixels in letters
function drawLetter($b, $image, $x, $y, $color)
{
	for($i=0;$i<sizeof($b);$i++)
	{
		for($j=0;$j<sizeof($b[0]);$j++)
		{
			if($b[$i][$j] == 1)
			{
				ImageSetPixel($image, $x + $j, $y + $i, $color);
			}
		}
	}
	$x_start = $x_start + 15;
}
drawLetter($letterJ, $im, $x_start, $y_start, $color);
$x_start = $x_start + 15;
drawLetter($letterU, $im, $x_start, $y_start, $color);
$x_start = $x_start + 15;
drawLetter($letterB, $im, $x_start, $y_start, $color);
$x_start = $x_start + 15;
drawLetter($letterB, $im, $x_start, $y_start, $color);
$x_start = $x_start + 15;
drawLetter($letterA, $im, $x_start, $y_start, $color);
$x_start = $x_start + 15;

ImagePNG($im);
ImageDestroy($im);
?>

```

Once I have more time to work on it, I will make the code better, shorter, and more efficient. 🙂 But if you are interested then I might as well show you now 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:24am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/6 "2003-06-27T05:24:31Z")

</div>

> \*Originally posted by Jubba \*  
> \*\*here is what I have so far!

\*\*  
that’s awesome really… im impressed =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:25am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/7 "2003-06-27T05:25:41Z")

</div>

I’m excited. This will end up being my footer but completely code generated and entirely random. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:32am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/8 "2003-06-27T05:32:46Z")

</div>

lol, now it should show up as random bgcolors…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 5:37am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/9 "2003-06-27T05:37:50Z")

</div>

awesome!

when i grow up, i wanna be just like you! 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 28, 2003, 3:24am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/10 "2003-06-28T03:24:16Z")

</div>

> \*Originally posted by Jubba \*  
> \*\*lol, now it should show up as random bgcolors… \*\*

You gunna share the code? :chinaman:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 28, 2003, 3:28am UTC](https://forum.kirupa.com/t/stupid-image-functions/24203/11 "2003-06-28T03:28:34Z")

</div>

no 😛

yeah once I fix it up a bit. I started working on something else as well (can’t stay focused for too long on one thing…)
