Re: EXIF support in PNG

Glenn Randers-Pehrson <[email protected]>
Newsgroups gmane.comp.graphics.png.general
Message-ID <CA+PdXcuaNL1DzsZbgFU4hnKTADPAkWNUYq9EHc66t9h3Ro=NBQ@mail.gmail.com>
On Thu, Jan 5, 2017 at 10:06 AM, Glenn Randers-Pehrson <[email protected]>
wrote:

>
>
> On Wed, Jan 4, 2017 at 11:10 PM, John Bowler <
> [email protected]> wrote:
>
>> On Wed, Jan 4, 2017 at 8:02 PM, Glenn Randers-Pehrson <[email protected]>
>> wrote:
>> > It's more like about 25 lines of Fortran in my case,
>> > assuming adler32 and crc32 functions are available, compared
>> > to around 10 lines to write a raw EXIF profile wrapped in
>> > an EXIF chunk length, "eXIf", data, and crc.
>>
>> Ok, please post those 25 lines.
>>
>

glenn.rp> cat dunflate.f
      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     FIRST DRAFT 5 January 2017
c
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 = 8,30 (32k+30)

      remaining_length = deflated_bytes

c     if (not last block i.e., remaining_length > 64k-1)
c         block header:
c           128 (1, 00, xxxxx) [check on position of the "1"]
c           64k-1 (2 bytes block_len)
c           0     (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           0 (0, 00, xxxxx)
c           block_len = 2 bytes, lsb first)
c           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 "0" (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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.