In order to change the opacity of a sprite you need to assign a color first.
image = GetComponent<Image>(); var tempColor = image.color; tempColor.a = 1f; image.color = tempColor;