U
    {hZ                     @   s   d dl Z d dlm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 e Zdd Zd ddZd!ddZd"ddZd#ddZd$ddZd%ddZdd ZdS )&    N)BytesIO)settings)serializers)	ImageFile)get_image_modelc                 C   sl   t jt j| jj\}}d|krRd|dd dd dd dd }tj	 d| d| | S )	z8
    Get the generated filename for a resized image
    zformat-.   -r   ZjpegZjpgzimages/)
ospathsplitextbasenamefilenamesplitreplacer   Z	MEDIA_URL)imageZ
filterspecr   ext r   b/var/www/dating/data/www/fatepal.com/env/lib/python3.8/site-packages/wagtail/images/tests/utils.pyget_test_image_filename   s    $ r   test.pngwhitei  i  c                 C   s.   t  }tjd||}||d t|| dS )NRGBAZPNGr   r   PILImagenewsaver   filenamecoloursizefr   r   r   r   get_test_image_file   s    r&   c                 C   s.   t  }tjd||}||d t|| dS )Nr   ZAVIFr   r   r!   r   r   r   get_test_image_file_avif"   s    r'   test.jpgc                 C   s.   t  }tjd||}||d t|| dS )NRGBZJPEGr   r   r!   r   r   r   get_test_image_file_jpeg)   s    r*   	test.webpc                 C   s.   t  }tjd||}||d t|| dS )Nr)   ZWEBPr   r   r!   r   r   r   get_test_image_file_webp0   s    r,   	test.tiffc                 C   s.   t  }tjd||}||d t|| dS )Nr)   ZTIFFr   r   r!   r   r   r   get_test_image_file_tiff7   s    r.   test.svgd   0 0 100 100c                 C   s4   d| d| d| d}t | d}t|| S )Nz
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" width="z
" height="z" viewBox="z">
</svg>
    zutf-8)r   stripencoder   )r"   widthheightZview_boxZimgr%   r   r   r   get_test_image_file_svg>   s    r6   c                	   C   s(   t tddddddddgd jS )	Npythonzmissing imager0   z!original_images/missing-image.jpg)titler5   r   r4   zwagtailimages.image)fieldsmodelr   )listr   Zdeserializeobjectr   r   r   r   get_test_bad_imageK   s    r=   )r   r   r   )r   r   r   )r(   r   r   )r+   r   r   )r-   r   r   )r/   r0   r0   r1   )r
   ior   Z	PIL.Imager   Zdjango.confr   Zdjango.corer   Zdjango.core.files.imagesr   Zwagtail.imagesr   r   r   r&   r'   r*   r,   r.   r6   r=   r   r   r   r   <module>   s&   




       
