File: //lib/python3/dist-packages/sphinx/util/__pycache__/png.cpython-310.pyc
o
$�aA � @ sl d Z ddlZddlZddlmZ dZdZe�dd�ZdZ d Z
d
edee fdd
�Z
d
ededdfdd�ZdS )z�
sphinx.util.png
~~~~~~~~~~~~~~~
PNG image manipulation helpers.
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�Optional� � �!i�
s
tEXtDepth s IEND�B`��filename�returnc C s� t | d��2}|�tt d� |�t�}|�tt �s$ W d � dS t� d|dd� �d W d � S 1 s:w Y dS )zARead the special tEXt chunk indicating the depth from a PNG file.�rb� Nr � � r )
�open�seek�LEN_IEND� LEN_DEPTH�read�
startswith�DEPTH_CHUNK_LEN�DEPTH_CHUNK_START�struct�unpack)r �f�
depthchunk� r �1/usr/lib/python3/dist-packages/sphinx/util/png.py�read_png_depth s
�$�r �depthc C s� t �d|�}t| d��0}|�t d� |�tt | � t� t| �d@ }|�t �d|�� |�t
� W d � dS 1 s>w Y dS )z�Write the special tEXt chunk indicating the depth to a PNG file.
The chunk is placed immediately before the special IEND chunk.
r zr+br
l �� z!IN)r �packr
r r �writer r �binascii�crc32�
IEND_CHUNK)r r �datar �crcr r r �write_png_depth# s "�r$ )�__doc__r r �typingr r r r r r r! �str�intr r$ r r r r �<module> s