← Back
Editing: images.cpython-311.pyc
� �|�e � �J � d Z ddlZddlZddlmZ G d� de� � Zdd�ZdS ) zO Utility functions for handling images. Requires Pillow as you might imagine. � N)�Filec �D � e Zd ZdZed� � � Zed� � � Zd� ZdS )� ImageFilez� A mixin for use alongside django.core.files.base.File, which provides additional features for dealing with images. c �6 � | � � � d S )Nr ��_get_image_dimensions��selfs �:/usr/lib/python3/dist-packages/django/core/files/images.py�widthzImageFile.width � � ��)�)�+�+�A�.�.� c �6 � | � � � d S )N� r r s r �heightzImageFile.height r r c � � t | d� � s1| j }| � � � t | |�� � | _ | j S )N�_dimensions_cache)�close)�hasattr�closed�open�get_image_dimensionsr )r r s r r zImageFile._get_image_dimensions sH � ��t�0�1�1� M��K�E��I�I�K�K�K�%9�$�e�%L�%L�%L�D�"��%�%r N)�__name__� __module__�__qualname__�__doc__�propertyr r r � r r r r sc � � � � � �� � �/� /� �X�/� �/� /� �X�/�&� &� &� &� &r r Fc �6 � ddl m} |� � � }t | d� � r,| }|� � � }|� d� � nt | d� � }d} d} |� |� � }|sn� |� |� � nY# t j $ r,}|j d � d� � rn� Y d }~n#d }~wt j $ r Y nt $ r Y nw xY w|j r8|j j |r|� � � S |� |� � S |d z }�� |r|� � � dS |� |� � dS # |r|� � � w |� |� � w xY w)z� Return the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state. r )r �read�rbTi r zError -5N� )NN)�PILr �Parserr �tell�seekr r �feed�zlib�error�args� startswith�struct�RuntimeError�image�sizer ) �file_or_pathr �PillowImageFile�p�file�file_pos� chunk_size�data�es r r r ! s� � � 1�0�0�0�0�0���� � �A��|�V�$�$� ����9�9�;�;��� � �!������L�$�'�'����# � � � ��9�9�Z�(�(�D�� �� ����t�������:� � � � �6�!�9�'�'� �3�3� ��� �D�D�D�D����� �<� � � � ��� � � � �� ���� �w� $��w�|� � ��J�J�L�L�L�L��I�I�h����� �!�O�J�1 �2 �� ��J�J�L�L�L�L�L��I�I�h������� � ��J�J�L�L�L�L��I�I�h�������sT �*E* �B �E* �C2�+"C� E* �C2�$E* �& C2�/E* �1C2�2E* �4E* �*.F)F)r r, r( �django.core.filesr r r r r r �<module>r9 s} ��� � � � � � ���� "� "� "� "� "� "�&� &� &� &� &�� &� &� &�*3 � 3 � 3 � 3 � 3 � 3 r
Save File
Cancel