This is for GIMP
Let's say you have a regular colour photograph like this - I've just chosen something random, but it should work with almost any photographic image. Note that this will only really work with colours which contrast, for example if one is brighter than the other. Colours which are too similar in brightness won't work well because photographs need both lighter and darker colours to look realistic.
For the sake of this mini tutorial, let's say you have a light blue, and a darker grey.
Do Image > Mode > Greyscale, then do Image > Mode > RGB
Set the foreground colour as the darker grey colour, and the lighter blue colour as the background colour. If instead your blue is darker, then make that the foreground colour and the lighter grey as the background colour.
If you have specific colours and know the hex code, you can enter it here
- Open the gradient panel, and select the gradient that says: FG to BG (RGB)
- Do Colors > Map > Gradient Map
Here's the result
Here's another example using a darker green and lighter red
If you feel these are little too extreme, or unrealistic, then you could have the original photograph on one layer, and the gradient map effect on a layer above with reduced opacity. This will kind of fade the effect.