In the first example, you're getting the PNG file as a string (still encoded as a PNG). In the second example, you're getting the raw pixels of the decoded image represented as bytes in a string.
Aha.. Can I convert the string of bytes from the second example to an image object again?
Basically I want to send an image object to another love process over the network. So I'm trying to find out my alternatives. Since I will already have the image object loaded from file I'd like to be able to do this without having to read from the filesystem again.
I'd recommend sending the encoded data anyway, because it's a lot smaller, so I would tell you to look at [wiki]ImageData:encode[/wiki], but it only supports writing to disk as well, sadly.
Bumping this because slime has just told me on IRC how to turn an ImageData's string representation back into an ImageData instance. You can make use of the FFI library which allows you to call external C functions. We are making use of FFI's copy() method: