Telling whether a random image employs linear or sRGB color values is usually a hard task. However, linear space is certainly the rarest.
In the more common case that the texture image is gamma corrected already, color values are gamma compressed a second time in the write_color function, and the resulting texture appears brighter than the original image, like in the example from the book.
I suggest to gamma decode colors after the image is loaded, or at least to mention the issue because it is very common.