o
    vhR                     @   s:   d dl mZmZ dd Zdd ZeejdeZdd Zd	S )
   )Image	ImageModec                 C   s(   t | j}| j\}}|| t|j S )z Return the number of color values in the input image --
        this is the number of pixels times the band count
        of the image.
    )r   getmodemodesizelenbands)imagemode_descriptorwidthheight r   U/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pilkit/processors/utils.pycolor_count   s   
r   c                    sJ   ddl mm} tt|   fdd|  D }|fdd|D  S )z0 Calculate the entropy of an images' histogram.     )log2fsumc                 3   s    | ]}|  V  qd S )Nr   ).0histocol)histosumr   r   	<genexpr>   s    z'histogram_entropy_py.<locals>.<genexpr>c                 3   s$    | ]}|d kr| | V  qdS )g        Nr   )r   p)r   r   r   r      s   " )mathr   r   floatr   	histogram)r	   r   	histonormr   )r   r   r   histogram_entropy_py   s   r   entropyc                 C   s$   |    | jdu r| S | | jjS )z1 Convert a palette image to a non-palette image. N)loadpaletteconvertr   )r	   r   r   r   resolve_palette   s   
r!   N)libr   r   r   r   getattrhistogram_entropyr!   r   r   r   r   <module>   s
    		