MCPcopy Index your code
hub / github.com/python-openxml/python-docx / _iter_chunk_offsets

Method _iter_chunk_offsets

src/docx/image/png.py:150–165  ·  view source on GitHub ↗

Generate a (chunk_type, chunk_offset) 2-tuple for each of the chunks in the PNG image stream. Iteration stops after the IEND chunk is returned.

(self)

Source from the content-addressed store, hash-verified

148 yield chunk
149
150 def _iter_chunk_offsets(self):
151 """Generate a (chunk_type, chunk_offset) 2-tuple for each of the chunks in the
152 PNG image stream.
153
154 Iteration stops after the IEND chunk is returned.
155 """
156 chunk_offset = 8
157 while True:
158 chunk_data_len = self._stream_rdr.read_long(chunk_offset)
159 chunk_type = self._stream_rdr.read_str(4, chunk_offset, 4)
160 data_offset = chunk_offset + 8
161 yield chunk_type, data_offset
162 if chunk_type == "IEND":
163 break
164 # incr offset for chunk len long, chunk type, chunk data, and CRC
165 chunk_offset += 4 + 4 + chunk_data_len + 4
166
167
168def _ChunkFactory(chunk_type, stream_rdr, offset):

Calls 2

read_longMethod · 0.80
read_strMethod · 0.80