+
    i                          ^RI HtHt ^RIHt ^RIHtHt ^RIH	t	  ! R R]	4      t
 ! R R4      t ! R	 R
4      t ! R R4      tR t ! R R4      t ! R R]4      t ! R R]4      tR# )   )	MIME_TYPEPNG_CHUNK_TYPE)InvalidImageStreamError)
BIG_ENDIANStreamReader)BaseImageHeaderc                   T   a  ] tR t^t o Rt]R 4       t]R 4       t]R 4       t	Rt
V tR# )Pngz#Image header parser for PNG images.c                "    \         P                  # )zMMIME content type for this image, unconditionally `image/png` for PNG
images.)r   PNGselfs   &U/Users/agent/.openclaw/workspace/.venv/lib/python3.14/site-packages/docx/image/png.pycontent_typePng.content_type
   s     }}    c                    R# )z8Default filename extension, always 'png' for PNG images.png r   s   &r   default_extPng.default_ext   s     r   c                    \         P                  V4      pVP                  pVP                  pVP                  pVP
                  pV ! W4WV4      # )zOReturn a |Png| instance having header properties parsed from image in
`stream`.)
_PngParserparsepx_width	px_heighthorz_dpivert_dpi)clsstreamparserr   r   r   r   s   &&     r   from_streamPng.from_stream   sG     !!&)??$$	????8;;r   r   N)__name__
__module____qualname____firstlineno____doc__propertyr   r   classmethodr"   __static_attributes____classdictcell__)__classdict__s   @r   r
   r
      sB     - 
   
< 
<r   r
   c                      a a ] tR t^#t oRtV 3R lt]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R 4       tR	tVtV ;t# )
r   zNParses a PNG image stream to extract the image properties found in its chunks.c                8   < \         \        V `  4        Wn        R # N)superr   __init___chunks)r   chunks	__class__s   &&r   r2   _PngParser.__init__&   s    j$(*r   c                <    \         P                  V4      pV ! V4      # )zfReturn a |_PngParser| instance containing the header properties parsed from
the PNG image in `stream`.)_Chunksr"   )r   r    r4   s   && r   r   _PngParser.parse*   s     $$V,6{r   c                F    V P                   P                  pVP                  # )z.The number of pixels in each row of the image.)r3   IHDRr   r   r;   s   & r   r   _PngParser.px_width1   s     ||  }}r   c                F    V P                   P                  pVP                  # )z2The number of stacked rows of pixels in the image.)r3   r;   r   r<   s   & r   r   _PngParser.px_height7   s     ||  ~~r   c                    V P                   P                  pVf   ^H# V P                  VP                  VP                  4      # )zwInteger dots per inch for the width of this image.

Defaults to 72 when not present in the file, as is often the case.
)r3   pHYs_dpiunits_specifierhorz_px_per_unitr   rA   s   & r   r   _PngParser.horz_dpi=   8     ||  <yy--t/D/DEEr   c                    V P                   P                  pVf   ^H# V P                  VP                  VP                  4      # )zxInteger dots per inch for the height of this image.

Defaults to 72 when not present in the file, as is often the case.
)r3   rA   rB   rC   vert_px_per_unitrE   s   & r   r   _PngParser.vert_dpiH   rG   r   c                Z    V ^8X  d$   V'       d   \        \        VR,          4      4      # ^H# )zOReturn dots per inch value calculated from `units_specifier` and
`px_per_unit`.g
F%u?)intround)rC   px_per_units   &&r   rB   _PngParser._dpiS   s&     aKu[61233r   r3   )r$   r%   r&   r'   r(   r2   r*   r   r)   r   r   r   r   staticmethodrB   r+   r,   __classcell__r5   r-   s   @@r   r   r   #   s     X    
  
 F F F F   r   r   c                   l   a a ] tR t^\t oRtV 3R lt]R 4       t]R 4       t	]R 4       t
R tRtVtV ;t# )r8   z8Collection of the chunks parsed from a PNG image stream.c                L   < \         \        V `  4        \        V4      V n        R # r0   )r1   r8   r2   listr3   )r   chunk_iterabler5   s   &&r   r2   _Chunks.__init___   s    gt%'N+r   c                n    \         P                  V4      p\        VP                  4       4      pV ! V4      # )zBReturn a |_Chunks| instance containing the PNG chunks in `stream`.)_ChunkParserr"   rV   iter_chunks)r   r    chunk_parserr4   s   &&  r   r"   _Chunks.from_streamc   s1     $//7l..016{r   c                L    R pV P                  V4      pVf   \        R4      hV# )zIHDR chunk in PNG image.c                 <    V P                   \        P                  8H  # r0   )	type_namer   r;   chunks   &r   <lambda>_Chunks.IHDR.<locals>.<lambda>m       eoo1D1DDr   zno IHDR chunk in PNG image)_find_firstr   )r   matchr;   s   &  r   r;   _Chunks.IHDRj   s0     E&<)*FGGr   c                *    R pV P                  V4      # )z2PHYs chunk in PNG image, or |None| if not present.c                 <    V P                   \        P                  8H  # r0   )r`   r   rA   ra   s   &r   rc   _Chunks.pHYs.<locals>.<lambda>v   re   r   )rf   )r   rg   s   & r   rA   _Chunks.pHYss   s     E&&r   c                P    V P                    F  pV! V4      '       g   K  Vu # 	  R# )zGReturn first chunk in stream order returning True for function `match`.NrP   )r   rg   rb   s   && r   rf   _Chunks._find_firsty   s#    \\EU|| " r   rP   )r$   r%   r&   r'   r(   r2   r*   r"   r)   r;   rA   rf   r+   r,   rR   rS   s   @@r   r8   r8   \   sS     B,     ' '
 r   r8   c                   R   a a ] tR t^t oRtV 3R lt]R 4       tR tR t	Rt
VtV ;t# )rZ   z(Extracts chunks from a PNG image stream.c                8   < \         \        V `  4        Wn        R # r0   )r1   rZ   r2   _stream_rdr)r   
stream_rdrr5   s   &&r   r2   _ChunkParser.__init__   s    lD*,%r   c                2    \        V\        4      pV ! V4      # )z\Return a |_ChunkParser| instance that can extract the chunks from the PNG
image in `stream`.)r   r   )r   r    rr   s   && r   r"   _ChunkParser.from_stream   s     "&*5
:r   c              #  t   "   V P                  4        F  w  r\        WP                  V4      pVx  K!  	  R# 5i)zyGenerate a |_Chunk| subclass instance for each chunk in this parser's PNG
stream, in the order encountered in the stream.N)_iter_chunk_offsets_ChunkFactoryrq   )r   
chunk_typeoffsetrb   s   &   r   r[   _ChunkParser.iter_chunks   s4      #'":":"<J!*.>.>GEK #=s   68c              #     "   ^p V P                   P                  V4      pV P                   P                  ^V^4      pV^,           pW43x  VR8X  d   R# V^V,           ^,           ,          pKi  5i)zGenerate 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.
IENDN)rq   	read_longread_str)r   chunk_offsetchunk_data_lenry   data_offsets   &    r   rw    _ChunkParser._iter_chunk_offsets   sq      !--77EN))221lAFJ&*K))V#EN2Q66Ls   A,A.)rq   )r$   r%   r&   r'   r(   r2   r*   r"   r[   rw   r+   r,   rR   rS   s   @@r   rZ   rZ      s0     2&  7 7r   rZ   c                    \         P                  \        \         P                  \        /pVP                  V \        4      pVP                  WV4      # )zeReturn a |_Chunk| subclass instance appropriate to `chunk_type` parsed from
`stream_rdr` at `offset`.)r   r;   
_IHDRChunkrA   
_pHYsChunkget_Chunkfrom_offset)ry   rr   rz   chunk_cls_map	chunk_clss   &&&  r   rx   rx      sH     	ZZM !!*f5I  @@r   c                   V   a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t	Rt
VtV ;t# )r   zMBase class for specific chunk types.

Also serves as the default chunk type.
c                8   < \         \        V `  4        Wn        R # r0   )r1   r   r2   _chunk_type)r   ry   r5   s   &&r   r2   _Chunk.__init__   s    fd$&%r   c                    V ! V4      # )z@Return a default _Chunk instance that only knows its chunk type.r   )r   ry   rr   rz   s   &&&&r   r   _Chunk.from_offset   s     :r   c                    V P                   # )z.The chunk type name, e.g. 'IHDR', 'pHYs', etc.r   r   s   &r   r`   _Chunk.type_name   s     r   r   )r$   r%   r&   r'   r(   r2   r*   r   r)   r`   r+   r,   rR   rS   s   @@r   r   r      s<     
&        r   r   c                   f   a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t	]R 4       t
RtVtV ;t# )r   z*IHDR chunk, contains the image dimensions.c                F   < \         \        V `  V4       W n        W0n        R # r0   )r1   r   r2   	_px_width
_px_height)r   ry   r   r   r5   s   &&&&r   r2   _IHDRChunk.__init__   s    j$(4!#r   c                Z    VP                  V4      pVP                  V^4      pV ! WV4      # )ztReturn an _IHDRChunk instance containing the image dimensions extracted from
the IHDR chunk in `stream` at `offset`.)r~   )r   ry   rr   rz   r   r   s   &&&&  r   r   _IHDRChunk.from_offset   s3     ''/((3	:33r   c                    V P                   # r0   )r   r   s   &r   r   _IHDRChunk.px_width   s    ~~r   c                    V P                   # r0   )r   r   s   &r   r   _IHDRChunk.px_height   s    r   )r   r   )r$   r%   r&   r'   r(   r2   r*   r   r)   r   r   r+   r,   rR   rS   s   @@r   r   r      sN     4$
 4 4     r   r   c                   v   a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t	]R 4       t
]R 4       tRtVtV ;t# )r   z/PYHs chunk, contains the image dpi information.c                R   < \         \        V `  V4       W n        W0n        W@n        R # r0   )r1   r   r2   _horz_px_per_unit_vert_px_per_unit_units_specifier)r   ry   rD   rI   rC   r5   s   &&&&&r   r2   _pHYsChunk.__init__   s$    j$(4!1!1 /r   c                ~    VP                  V4      pVP                  V^4      pVP                  V^4      pV ! WWV4      # )zsReturn a _pHYsChunk instance containing the image resolution extracted from
the pHYs chunk in `stream` at `offset`.)r~   	read_byte)r   ry   rr   rz   rD   rI   rC   s   &&&&   r   r   _pHYsChunk.from_offset   sH     &//7%//:$..vq9:1ASSr   c                    V P                   # r0   )r   r   s   &r   rD   _pHYsChunk.horz_px_per_unit       %%%r   c                    V P                   # r0   )r   r   s   &r   rI   _pHYsChunk.vert_px_per_unit   r   r   c                    V P                   # r0   )r   r   s   &r   rC   _pHYsChunk.units_specifier   s    $$$r   )r   r   r   )r$   r%   r&   r'   r(   r2   r*   r   r)   rD   rI   rC   r+   r,   rR   rS   s   @@r   r   r      sd     90 T T & & & & % % %r   r   N)	constantsr   r   
exceptionsr   helpersr   r   imager   r
   r   r8   rZ   rx   r   r   r   r   r   r   <module>r      sf    0 / - "</ <86 6r" "J$7 $7NA   * 2% %r   