I think this is very possible to do as a separate package, with RECOIL as it is. Import only of course. (Exporting is obviously beyond the scope of RECOIL.)
Here is a less intrusive patch against the current version. It add an optional argument to SetSize() which lets the caller request indexed pixels (instead of RGB pixels). In that case the image will never be converted to RGB then converted to PNG, and the original palette will of course be used. Everything will still function exactly the same from the API user perspective. It would also be easy for a decoder to first request indexed pixels and at a later stage upgrade to RGB pixels (because it needs...
As far as I'm concerned this is issue is basically solved now with the new API. Recoil just need to provide the info for all resolutions. IMHO calculating the horisontal and vertical pixels per meter for some TV of any size is sufficient since it's the ratio between the values that matters the most.
I don't have any file created with the actual Image System application. So I don't know if the 192 unknown bytes should actually contain something other than zeros (but it shouldn't affect the decoding in any case). I attach one file converted with tomseditor.com (which doesn't even try to preserve any color and seems to get the load address wrong) and one converted with pyriel. Both loads fine in tomseditor.
Support C64 Hires Image System files
I don't know enough about different Amiga graphic hardware (I'm only really familiar with the original Amiga 500), but I assumed CAMG could be interpreted slightly differently depending on if you have AGA or not. Since CAMG is the only way to activate HAM (?) I also assumed it could be used by encoders outside the Amiga world. (I'm working on an ILBM encoder with HAM support myself and I would be really surprised if I'm the first one.) Regarding the aspect ratio, I didn't mean the aspect ratio of...
In my opinion an image for the C64 should generally have all 16 colors in the palette, even if the image only contains a subset. Perhaps if the format has a concept of a palette with fewer colors, only those colors should be included. Does such formats exist? For multi palette images I don't think the concept of an original palette is relevant, it's okay to treat them as not having a palette (same as with HAM). For flickering images it would be ideal if each frame could be accessed individually,...
ILBM has fields in the header for defining fine grained pixel aspect ratio (just as the pHYs chunk of PNG), even if it's often misused. I detect misuse by calculating the claimed screen aspect ratio, if it adds up to 4:3 the information is most likely correct. So (at least in some cases) it doesn't need to be mapped to any particular hardware resolution to get the correct pixel aspect ratio. It would be nice to be able to query RECOIL about the more exact pixel aspect ratio with an argument telling...