Ticket #69 (closed task: fixed)

Opened 2 years ago

Last modified 1 year ago

Use EncodedFile, Link and Fragment for PNG, GIF, (...) parsers

Reported by: anonymous Assigned to: haypo
Priority: normal Milestone:
Component: parser Keywords:
Cc:

Description

It would be cool to be able to read PNG image data, here is an example for picture with two chunks:

def parseImageData(parent):
    import zlib
    from hachoir_core.field import EncodedFile, Field
    from hachoir_core.stream import StringInputStream
    from hachoir_core.bits import str2hex

    def deflate(stream, field):
        # TODO: Write lazy decompressor
        data = stream.readBytes(0, stream.size//8)
        stream =Field.createInputStream(field["/data[1]/image_data"])
        data += stream.readBytes(0, stream.size//8)
        warning("data=%r (len %s)" % (data[:20], len(data)))
        data = zlib.decompress(data)
        source = "deflate:source=(%s), offset=%s" % (stream.source, field.absolute_address)
        warning("data=%r (len %s)" % (data[:20], len(data)))
        return StringInputStream(data, source)
    yield EncodedFile(parent, "image_data", parent["size"].value, deflate)

zlib doesn't work with GIF parse.

Link/Fragment have to be used in EXIF parser.

Attachments

Change History

01/20/07 04:52:19 changed by jm

Done for the png parser in [1758].

07/17/07 23:09:59 changed by haypo

  • status changed from new to closed.
  • resolution set to fixed.

Add/Change #69 (Use EncodedFile, Link and Fragment for PNG, GIF, (...) parsers)




Action