I know nothing at all about Python, but I know a little about ImageMagick which is available here and has Python bindings.
If you run this ImageMagick command at the command line:
convert -size 100x500 gradient:#00ff00-#ff0000 full.jpg
you will get a 100x500 pixel image, called full.jpg
, with a gradient from green to red that looks like this:
If you then run the following command:
convert full.jpg -gravity North -background gray -crop 100x250+0+0! -extent 100x500 crop.jpg
you will get a new image, called crop.jpg
, that looks like this:
The 250
is the number that will control the amount that gets greyed out, so try varying that. So if your input number you mentioned is 1
, maybe you would use 50
in place of 250
(because 1/10th of the 500px image height is 50px), if it is 2
maybe use 100
in place of 250
...
And maybe that will help - maybe it won't!!!