Issue #346: Import and export safe-to-copy PNG chunks
This patch attempts to resolve issue #346 (closed).
PNGs can contain other data chunks besides image-related ones. Currently, we ignore these and only use chunks with named functions in libpng (such as png_get_IHDR ()
).
This patch uses the function png_set_read_user_chunk_fn ()
to set up a callback to access these additional chunks. If they are marked as safe to copy (the last byte of the 4-byte long name is lowercase), it stores as a parasite. On export, the parasite data is retrieved and exported before the image data using png_write_chunk ()
.
@Wormnest Hi! Since this is metadata-related, I'm bothering you as usual.
Edit: Adding a real-world sample file. ZDoom adds a 'grAb' chunk which stores sprite offsets. With this patch, GIMP now loads and saves the chunk correctly.