How would I read a heightmap in a script?

Hello, I am making a game.

And I need to generate simple terrain.
So basically it will be flat but in random places there might spawn hills. So I am thinking about generating a custom heightmap when generating the random terrain and then somehow reading the custom heightmap to then generate the terrain.

I have tried looking on the forums, but they only talk about making an external program to read heightmaps then feeding it into a script

But I want it all to happen in a script.

Thanks in advance.