o
    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|v r)d|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   jpegjpgzimages/)
ospathsplitextbasenamefilenamesplitreplacer   	MEDIA_URL)image
filterspecr   ext r   Z/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/images/tests/utils.pyget_test_image_filename   s   $r   test.pngwhitei  i  c                 C   .   t  }tjd||}||d t|| dS )NRGBAPNGr   r   PILImagenewsaver   filenamecoloursizefr   r   r   r   get_test_image_file      r,   c                 C   r   )Nr   AVIFr!   r"   r'   r   r   r   get_test_image_file_avif"   r-   r/   test.jpgc                 C   r   )NRGBJPEGr!   r"   r'   r   r   r   get_test_image_file_jpeg)   r-   r3   	test.webpc                 C   r   )Nr1   WEBPr!   r"   r'   r   r   r   get_test_image_file_webp0   r-   r6   	test.tiffc                 C   r   )Nr1   TIFFr!   r"   r'   r   r   r   get_test_image_file_tiff7   r-   r9   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heightview_boximgr+   r   r   r   get_test_image_file_svg>   s   
rC   c                	   C   s(   t tddddddddgd jS )	Npythonzmissing imager;   z!original_images/missing-image.jpg)titler@   r   r?   zwagtailimages.image)fieldsmodelr   )listr   deserializeobjectr   r   r   r   get_test_bad_imageK   s"   rK   )r   r   r   )r0   r   r   )r4   r   r   )r7   r   r   )r:   r;   r;   r<   )r   ior   	PIL.Imager#   django.confr   django.corer   django.core.files.imagesr   wagtail.imagesr   r$   r   r,   r/   r3   r6   r9   rC   rK   r   r   r   r   <module>   s"    





