Re: EXIF support in PNG
Glenn Randers-Pehrson <[email protected]>
| Newsgroups | gmane.comp.graphics.png.general |
|---|---|
| Message-ID | <CA+PdXctFEk4dgdnhaKc2Z2oddqgzY9PMBwHzCA80HK30t1z4VA@mail.gmail.com> |
Fixed up CMF bytes
program dunflate
c Written in 2017 by Glenn Randers-Pehrson <[email protected]>
c
c To the extent possible under law, the author has dedicated all
copyright
c and related and neighboring rights to this software to the public
domain
c worldwide. This software is distributed without any warranty.
c See <http://creativecommons.org/publicdomain/zero/1.0/>.
c
c DRAFT 0002 5 January 2017
c
c Demonstrates writing a PNG chunk with zlib-encoded but
c uncompressed data, in a form that any compliant zlib reader
c can decode. This demonstration uses the iCCP chunk
c but could also be used with zTXt or a proposed eXIf chunk.
c input (on stdin): a raw ICC profile
c output( on stdout): an iCCP chunk containing the profile in a
c zlib-encoded but uncompressed format.
c calculate ADLER32 over uncompressed
c data, get uncompressed data length
c (implementation detail: do this on
c a separate pre-pass or do it all in
c one pass.
c number_of_blocks =
c uncompressed_data_length / (64k-1)
c deflated_bytes = uncompressed_data_length
c + 5 * number_of_blocks
c zlib header:
c cmf = 0x08 0x1d (smallest window)
c
c in a 1x1 test file:
c 4944 4154 081d 0102 00fd ff00 0100 IDAT..........
c in a large test file (081d would still be OK):
c 4944 4154 7801 0043 b6bc 4900 IDATx..C..I.
remaining_length = deflated_bytes
c if (not last block i.e., remaining_length > 64k-1)
c block header:
c 0x01 (1, 00, xxxxx in little-endian order)
c 0xff 0xff (64k-1, 2 bytes block_len)
c 0x00 0x00 (2 bytes block_nlen)
c some data
c note: these blocks are 64k+4 bytes in length
remaining_data -= 64k-1
c else
c block header:
c 0x00 (0, 00, xxxxx)
c 0xnnnn block_len = 2 bytes, lsb first)
c 0xnnnn block_nlen = ~len (2 bytes, lsb first)
c remaining data
c note: this block is 5 to 64k+4 bytes in length
c calculate length and crc32 over
c "iCCP", zero, cmf, blocks, and adler32
c write length
c write "iCCP"
c write 0x00 (1 byte, "compression method")
c write zlib header
c write blocks
c write ADLER32
end
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
png-mng-misc mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/png-mng-misc