Files
LifeFaq/app/services/__pycache__/image_controller.cpython-312.pyc

52 lines
3.9 KiB
Plaintext
Raw Normal View History

2024-12-24 00:14:44 +01:00
<EFBFBD>
<00>=gg<67> <00><00>,<00>ddlZddlmZGd<03>d<04>Zy)<05>N)<01>Imagec <00>z<00>eZdZdefd<02>Zdedefd<05>Zdedededefd<08>Zd ed
ededefd <0B>Zdd ededed ededef d<0F>Z y)<12> ImageHandler<65>base_dirc<00><00>||_y)zh
Initialize the ImageHandler.
:param base_dir: Base directory for storing and retrieving images.
N)r)<02>selfrs <20>D/home/hjess/PycharmProjects/LifeFaq/app/services/image_controller.py<70>__init__zImageHandler.__init__s <00><00> <1B>$<24>-<2D><00>filename<6D>returnc<00>V<00>tjj|j|<01>S)z<>
Construct the full path for a given image file.
:param filename: Relative filename of the image.
:return: Full path to the image.
<09><04>os<6F>path<74>joinr)rr s r <00>get_image_pathzImageHandler.get_image_path s<00><00>
<0C><17><17><1C><1C>d<EFBFBD>m<EFBFBD>m<EFBFBD>X<EFBFBD> .<2E>.r <00>width<74>heightc <00>h<00>tjj|jd|<02>d|<03>d|<01><00><06>S)z<>
Construct the path for a resized image.
:param filename: Original image filename.
:param width: Desired width.
:param height: Desired height.
:return: Path to the resized image.
<09>resized_<64>x<>_r)rr rrs r <00>get_resized_image_pathz#ImageHandler.get_resized_image_paths0<00><00>
<0C><17><17><1C><1C>d<EFBFBD>m<EFBFBD>m<EFBFBD>x<EFBFBD><05>w<EFBFBD>a<EFBFBD><06>x<EFBFBD>q<EFBFBD><18>
<EFBFBD>%K<> L<>Lr <00> original_path<74> resized_pathc<00><><00>tjj|<02>sEtj|<01>5}|j ||f<02>}|j |d<01><02>ddd<03>yy#1swYyxYw)z<>
Resize and save the image if it doesn't already exist.
:param original_path: Path to the original image file.
:param resized_path: Path to save the resized image.
:param width: Desired width.
:param height: Desired height.
<09>JPEG)<01>formatN)rr<00>existsr<00>open<65>resize<7A>save)rrrrr<00>img<6D> img_resizeds r <00>resize_and_savezImageHandler.resize_and_save!s[<00><00>
<0C><17><17><1E><1E> <0C> %<25> <0A>
<EFBFBD>
<EFBFBD>=<3D>!<21>S<EFBFBD><15>*<2A>*<2A>e<EFBFBD>V<EFBFBD>_<EFBFBD>-<2D>K<EFBFBD><0F><14><14>\<5C>&<26><14>1<> "<22>!<21>
&<26>!<21>!<21>s <00>'A&<03>&A/<07>src<72> css_class<73>altc
<00>f<00>|j|<01>}tjj|<06>st d|<01><00><02><00>d|<02>d|<03>dtjj |<01><00><00>}|j |||<03>}|j||||<03>|rd|<04>d<06>nd} |rd|<05>d<06>nd}
d |<08>d
|<02>d |<03>d|
<EFBFBD>| <09>d <0C>
S) ar
Generate an HTML <img> tag and ensure the image exists with the specified dimensions.
:param src: Relative path to the original image.
:param width: Desired width of the image.
:param height: Desired height of the image.
:param css_class: Optional CSS class to add to the <img> tag.
:param alt: Alternative text for the image.
:return: HTML <img> tag.
zImage not found: rrrz class="<22>"<22>z alt="z <img src="/z " width="z
" height="<22>>)rrr<00>isfile<6C>FileNotFoundError<6F>basenamerr&) rr'rrr(r)r<00>resized_filenamer<00>
class_attr<EFBFBD>alt_attrs r <00>generate_image_tagzImageHandler.generate_image_tag/s<><00><00><17>%<25>%<25>c<EFBFBD>*<2A>-<2D> <0B><17><17><1E><1E> <0A> &<26> <1A>.<2E>s<EFBFBD>e<EFBFBD>4<> 5<>5<> <20><05>w<EFBFBD>a<EFBFBD><06>x<EFBFBD>q<EFBFBD><12><17><17>1A<31>1A<31>#<23>1F<31>0G<30>H<><12><15>,<2C>,<2C>S<EFBFBD>%<25><16>@<40>,<2C><07><16><16>}<7D>l<EFBFBD>E<EFBFBD>6<EFBFBD>B<>+4<><18>)<29><1B>A<EFBFBD>&<26><12>*<2A> #<23>v<EFBFBD>c<EFBFBD>U<EFBFBD>!<21>_<EFBFBD><12>(<28> <16>|<7C>n<EFBFBD>I<EFBFBD>e<EFBFBD>W<EFBFBD>J<EFBFBD>v<EFBFBD>h<EFBFBD>a<EFBFBD><08>z<EFBFBD>R\<5C>Q]<5D>]^<5E> _<>_r N)r,r,)
<EFBFBD>__name__<5F>
__module__<EFBFBD> __qualname__<5F>strr
r<00>intrr&r4<00>r r rrs<><00><00><1B>c<EFBFBD><1B>/<2F>C<EFBFBD>/<2F>C<EFBFBD>/<2F> M<01>C<EFBFBD> M<01><03> M<01>S<EFBFBD> M<01>S<EFBFBD> M<01> 2<>#<23> 2<>S<EFBFBD> 2<><13> 2<>VY<56> 2<>`<01>3<EFBFBD>`<01>s<EFBFBD>`<01>C<EFBFBD>`<01>C<EFBFBD>`<01>[^<5E>`<01>hk<68>`r r)r<00>PILrrr:r r <00><module>r<s<00><01> <09><15>D`<01>D`r