o
    ^"<f
                     @   s  d dl Z d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZ er+d dlmZ nzd dlmZ W n ey@   d dlZY nw dd Zd	d
 Zdd Zede_ee_dd Zede_ee_dd Zede_ee_dd Zede_ee_dd Zede_ee_dS )    N)messages)File)gettext_lazy)VERSION_QUALITY
STRICT_PIL)Imagec                 C   s
   | j dkS )zSet image filetyper   )filetype)
fileobject r
   J/var/www/html/kck/venv/lib/python3.10/site-packages/filebrowser/actions.pyapplies_to_all_images   s   
r   c              	   C   s(  |D ]}t j|j\}}|jj|j}t|}||}t	t
 }	z|j|	tj| tt j|jd  dkd W n tyR   |j|	tj| td Y nw z'|jj|j|	}
|
|jkrm|jjj|
|jdd |  W |	  |  n	|	  |  w t| tjtd|j  qdS )	zTranspose image   z.gif)formatqualityoptimize)r   r   T)allow_overwritez#Action applied successfully to '%s'N)ospathsplitextfilenamesitestorageopenr   	transposer   tempfileNamedTemporaryFilesave	EXTENSIONr   lowerIOErrormovedelete_versionscloser   add_messageSUCCESS_)requestfileobjects	operationr	   rootextfim	new_imagetmpfilesaved_underr
   r
   r   transpose_image   s,   

2



r0   c                 C      t | |d dS )zFlip image horizontallyr   Nr0   r&   r'   r
   r
   r   flip_horizontal4      r4   zFlip horizontalc                 C   r1   )zFlip image verticallyr   Nr2   r3   r
   r
   r   flip_vertical;   r5   r6   zFlip verticalc                 C   r1   )z!Rotate image 90 degrees clockwise   Nr2   r3   r
   r
   r   rotate_90_clockwiseB   r5   r8   u   Rotate 90° CWc                 C   r1   )z(Rotate image 90 degrees counterclockwise   Nr2   r3   r
   r
   r   rotate_90_counterclockwiseI   r5   r:   u   Rotate 90° CCWc                 C   r1   )zRotate image 180 degrees   Nr2   r3   r
   r
   r   
rotate_180P   r5   r<   u   Rotate 180°)r   r   django.contribr   django.core.filesr   django.utils.translationr   r%   filebrowser.settingsr   r   PILr   ImportErrorr   r0   r4   short_description
applies_tor6   r8   r:   r<   r
   r
   r
   r   <module>   s<   





