The PNG format has support for more-or-less arbitrary metadata. The PNG standard defines a PNG file, essentially a series of chunks, some of which are required (and contain the image data). Others, however, are optional. For example, there's a chunk for storing gamma information or histogram data.
In particular, there is a tEXt
chunk that can be used to store arbitrary key/value text pairs. This can be used to ship around any kind of arbitrary data you want, provided you can represent that data as text (which is fairly likely).
You will need a PNG library that allows you access and manipulate these additional chunks (such as the reference library), or you'll need to write one yourself. Then it's just a matter of choosing how to encode the data you want as key/value pairs. I'd suggest the following:
- choose key names that are prefixed with your project's name or code name as a way of creating a crude "namespace" system and avoid potential conflicts with other application's uses of the data
- don't try to store actual textures this way, store references to those textures that point within your game's own asset database
- data such as creature or object size, weight, et cetera -- simple scalars, basically -- can be trivially stored
In the interests of making a more complete answer, I'll also point out that there is another approach (previously documented by the @Vaughn and @Alexis's answers): encode the additional data you want directly in your image pixels, distributing your data across the low-order bits of the color channels. This approach doesn't require the use of extra metadata, which means you can implement it entirely without relying on it or worrying about external programs incorrectly handling that metadata. It's also got a very high "cool" factor, and because you only use low-order bits the image will still look correct to the human eye. However, it does mean your image size is a primary controlling factor for the amount of data you can store; if you need more storage you'd need to allocate more pixels to the image.
As others have pointed out, this process is known as steganography.