How can I extract raw []uint8 from an image?
The size on an 8-bit integer is, by definition, 8 bits (or 1 byte).
(Editing to remove erroneous information, which I'll repost for posterity below.)
The string representation being output is not one character per number - it's several (for example, the int you list first - 65
- is being represented by three characters - a 6, a 5, and a space. That would increase the expected size threefold, from 300k to 900k.
As for the rest, I would think that (as icza said in a comment) image compression may be the culprit.
(The irrelevant information I'd initially posted as part of my answer was:
Go has two character types,
byte
andrune
. A byte being used to store a character is the same size as a byte being used to store an integer - both are 8 bits. But a character being stored as arune
is going to be 32 bits (see https://www.callicoder.com/golang-basic-types-operators-type-conversion/). So, if the characters being written out arerune
s, that would explain a four-fold increase in size (because 32 / 8 = 4)...