
    h                     Z    d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d	dZ
 G d de	      Zy)
    )BytesIO)Image
ImageChops	ImageDraw)
processors)TestCasec                    g }t        |      D ]  }t        j                  | |d      }t        j                  |      }|d   dz  |z  |d   dz  |z  }	}|j                  ||	dz  |dz  |	dz  fd       |j                  |dz  |	|dz  |	d	z  fd
       |j                  |        t               }
|d   j                  |
|d|dd         t        j                  |
      }|S )N)   r
   r
   r   (               red   yellowT)formatsave_allappend_images)
ranger   newr   Draw	rectangleappendr   saveopen)moder   size	no_framesframesiimagedrawx_bity_bitwrite_toims               [/home/dcms/DCMS/lib/python3.12/site-packages/easy_thumbnails/tests/test_animated_formats.pycreate_animated_imager)      s    F9 		$o6~~e$Aw"}q($q'R-!*;uuqy%!)UQY?G	5%!)UQY?Je yH
1INN$fQRj   
H	B
 I    c                   *    e Zd Zd Zd Zd Zd Zd Zy)AnimatedFormatProcessorsTestsc                     d}t        |      }|j                  }| j                  ||       t        j                  |d      }|j                  }| j                  ||       | j                  |j
                  d       y )N   r   )d   r0   r)   n_framesassertEqualr   scale_and_cropr   selfr   r'   frames_count	processedprocessed_frames_counts         r(   
test_scalez(AnimatedFormatProcessorsTests.test_scale   sm    	"Y7{{y1--b*=	!*!3!3'=>4r*   c                     d}t        |      }|j                  }| j                  ||       t        j                  |dd      }|j                  }| j                  ||       | j                  |j
                  d       y )N	   r/   )i  i  T)cropr1   )r6   r    r'   r7   r8   r9   s         r(   test_scale_cropz-AnimatedFormatProcessorsTests.test_scale_crop(   so    "V4{{v.--b*4H	!*!3!3'=>4r*   c                 6   d}t        d      }|j                  }| j                  ||       t        j                  |d      }|j                  }| j                  ||       | j                  |j
                  d       | j                  |j                  d       y )N   png)r   T)bwL  rE   )r)   r2   r3   r   
colorspacer   r   r5   s         r(   test_colorspacez-AnimatedFormatProcessorsTests.test_colorspace2   s    	"%0{{y1))"6	!*!3!3'=>-6r*   c                    d}t        d|      }|j                  }| j                  ||       t        j                  |dd      }|j                  }| j                  ||       | j                  |j
                  d       y )N   webpr   r   T)detailsharpenrD   )r)   r2   r3   r   filtersr   r5   s         r(   test_filterz)AnimatedFormatProcessorsTests.test_filter?   sq    	"&IF{{y1&&r$E	!*!3!3'=>6r*   c                    d}t        d|      }|j                  }| j                  ||       t        j                  |dd      }|j                  }| j                  ||       | j                  |j
                  d       y )Nr<   rJ   rK   z#ff00ff)rE   i  )
backgroundr   )r)   r2   r3   r   rQ   r   r5   s         r(   test_backgroundz-AnimatedFormatProcessorsTests.test_backgroundJ   sq    	"&IF{{y1))"V	!*!3!3'=>6r*   N)__name__
__module____qualname__r:   r>   rG   rO   rR    r*   r(   r,   r,      s    557	7	7r*   r,   N)RGBgifrD   r@   )ior   PILr   r   r   easy_thumbnailsr   unittestr   r)   r,   rV   r*   r(   <module>r]      s%     , , & *77H 77r*   