I can't get hex value from shader directly using pyhon

I want to display textures in solid mode. If a shader have multiple texture maps and not the base color. Base color is defined by manipulating the value directly. In this case if in solid mode texture view is used we can only see the roughness or normal map not base color because its not present in image format. My solution is to create a new image of same color from base color and connect it to shader. Issue is I can’t seem to get the exact color from shader to create the image. I also tried gamma correction as well but it’s not the same. That is the reason why I need to extract hex value from the shader not rgb.