I've looked around but cant seem to find what I need.

I am looking for something that will allow the use of php gd to create an image from an image file but based on a percentage value that is passed to it which will be calculated from elsewhere, I need the image to be covered/overlayed with say a black rectangle the same size as the image but this percentage value would determine how much of the image shows.

So if percent passed to it was 0 then the entire image is hidden by the black rectangle, if 25% only the bottom 25 percent would be visible and the top 75% would be hidden by the rectangle and so on.

Anyone know of anything out there already that does this or the code to create a rectangle over an image but only covering the top xx percentage of the image based on a value passed to it.

Thanks in advance.