Extract the image metadata by reading the initial part of the PNG file up to the start of the ``IDAT`` chunk. All the chunks that precede the ``IDAT`` chunk are read and either processed for metadata or discarded. If the optional `lenient` argument e
(self, lenient=False)
| 1596 | raise FormatError("PNG file has invalid signature.") |
| 1597 | |
| 1598 | def preamble(self, lenient=False): |
| 1599 | """ |
| 1600 | Extract the image metadata by reading |
| 1601 | the initial part of the PNG file up to |
| 1602 | the start of the ``IDAT`` chunk. |
| 1603 | All the chunks that precede the ``IDAT`` chunk are |
| 1604 | read and either processed for metadata or discarded. |
| 1605 | |
| 1606 | If the optional `lenient` argument evaluates to `True`, |
| 1607 | checksum failures will raise warnings rather than exceptions. |
| 1608 | """ |
| 1609 | |
| 1610 | self.validate_signature() |
| 1611 | |
| 1612 | while True: |
| 1613 | if not self.atchunk: |
| 1614 | self.atchunk = self._chunk_len_type() |
| 1615 | if self.atchunk is None: |
| 1616 | raise FormatError("This PNG file has no IDAT chunks.") |
| 1617 | if self.atchunk[1] == b"IDAT": |
| 1618 | return |
| 1619 | self.process_chunk(lenient=lenient) |
| 1620 | |
| 1621 | def _chunk_len_type(self): |
| 1622 | """ |
no test coverage detected