# GD help

**URL:** <https://forum.kirupa.com/t/gd-help/307703>\
**Category:** programming\
**Created:** [April 8, 2010, 5:57pm UTC](https://forum.kirupa.com/t/gd-help/307703 "2010-04-08T17:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![W92Baj](https://avatars.discourse-cdn.com/v4/letter/w/a88e4f/32.png) [@W92Baj](https://forum.kirupa.com/u/W92Baj)\
**Post date:** [April 8, 2010, 5:57pm UTC](https://forum.kirupa.com/t/gd-help/307703/1 "2010-04-08T17:57:51Z")

</div>

There seems to be a shortage of GDlib tutorials out in the interweb.

I want to create an image of a solid block of random colour then mask it with a greyscale image so I end up with an image similar to the mask but with a random colour.

After a bit of hunting about I discovered the only way was to change each pixel colour of the mask image which seemed a bit longwinded. Then I found this on the php site:  
[http://www.php.net/manual/en/function.imagesavealpha.php](http://www.php.net/manual/en/function.imagesavealpha.php) - Top comment. Someone has written a function to do what I need. Hurrah.

However I have no idea how to get it working.

They say using the function is simple and I have done as they say but I get a huge row of gobbledegook.  
If I try adding a ‘header( “Content-type: image/png”);’ anywhere I get headers already sent warnings.

What am I doing wrong? :ponder:
