Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/willow/__pycache__/image.cpython-310.pyc

108 lines
11 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD>$<00>@s<>ddlZddlZddlmZddlmZmZddlmZddl Z ddl
m Z ddl m ZddlmZGd d
<EFBFBD>d
e<10>ZGd d <0C>d e<12>ZGd d<0E>d<0E>ZGdd<10>de<14>ZGdd<12>de<15>ZGdd<14>de<15>ZGdd<16>de<14>ZGdd<18>de<18>ZGdd<1A>de<18>ZGdd<1C>de<18>ZGdd<1E>de<18>ZGdd <20>d e<18>ZGd!d"<22>d"e<18>ZGd#d$<24>d$e<18>ZGd%d&<26>d&e<18>Z Gd'd(<28>d(e<18>Z!Gd)d*<2A>d*e<18>Z"e<0E>#<23>j$ee<0E>%<25>j$ee<0E>&<26>j$ee<0E>'<27>j$ee<0E>(<28>j$ee<0E>)<29>j$ed+ee<0E>*<2A>j$e e<0E>+<2B>j$e!e<0E>,<2C>j$e"i
Z-dS),<2C>N)<01>BytesIO)<02>NamedTemporaryFile<6C>SpooledTemporaryFile)<01>Optional)<01> ElementTree)<01>image<67>)<01>registryc@s eZdZdS)<02>UnrecognisedImageFormatErrorN)<03>__name__<5F>
__module__<EFBFBD> __qualname__<5F>rr<00>N/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/willow/image.pyr
sr
c@seZdZdZdS)<03>BadImageOperationErrorz<72>
Raised when the arguments to an image operation are invalid,
e.g. a crop where the left coordinate is greater than the right coordinate
N)r r r <00>__doc__rrrrrsrc@s<>eZdZedd<02><00>Zedd<04><00>Zeddd<07><01>Zeddd <09><01>Zd
d <0B>Z ed d <0A><00>Z
edd<0F><00>Z dde dfdd<14>Z defdd<17>ZdS)<1A>ImagecCsdS<00>Nr)<01>clsrrr<00>check<00>z Image.checkcCs
d|_|S<00>NT)<01>_willow_operation<6F><01>funcrrr<00> operation szImage.operationNc<00><00><00>fdd<02>}|S)Ncs<00><01>f|_|Sr)<01>_willow_converter_tor<00><02>cost<73>to_classrr<00>wrapper's
z#Image.converter_to.<locals>.wrapperr)r rr!rrr<00> converter_to%szImage.converter_tocr)NcsLt|d<01>sg|_t<02>t<03>r|j<01><04>fdd<03><08>D<00><01>|S|j<01><05><01>f<02>|S)N<>_willow_converter_fromcsg|]}|<01>f<02>qSrr)<02>.0<EFBFBD>sc)rrr<00>
<listcomp>4sz9Image.converter_from.<locals>.wrapper.<locals>.<listcomp>)<06>hasattrr#<00>
isinstance<EFBFBD>list<73>extend<6E>appendr<00>r<00>
from_classrrr!/s

<10>z%Image.converter_from.<locals>.wrapperr)r-rr!rr,r<00>converter_from-s zImage.converter_fromcsVzt<00>t<02><02>|<01>\<04>}<02>}Wnty t<04>jj<06>d|<01><02><03><01>w<00><00><01>fdd<03>}|S)Nz object has no attribute cs0<00>}<02>D]\}}||<02>}q<04>|g|<00>Ri|<01><01>Srr)<05>args<67>kwargsr<00> converter<65>_<><03>conversion_pathr<00>selfrrr!Es 
z"Image.__getattr__.<locals>.wrapper)r <00>find_operation<6F>type<70> LookupError<6F>AttributeError<6F> __class__r )r5<00>attrr2r!rr3r<00> __getattr__<s <04><02>zImage.__getattr__cCsXt<00>|<01>}|dur|<00>|<01>rd}t<03>|<02>}|s(|r$td|<02>dt<03>d<04><05><01>td<05><01>||<01>S)N<>svgz Cannot load z images (<28>)zUnknown image format)<06>filetype<70>guess_extension<6F> maybe_xml<6D>INITIAL_IMAGE_CLASSES<45>getr
)r<00>f<> image_format<61> initial_classrrr<00>openQs

<04>z
Image.opencCsF|<01>d<01>t<01>d<02>}|D]}|<02>|<03>r|<01>d<01>dSq |<01>d<01>dS)Nrs^\s*<TF)<04>seek<65>re<72>compile<6C>match)rrD<00>pattern<72>linerrrrAes



<02>
zImage.maybe_xmlT<6C>return<72> ImageFilecCs.|dvr
td|<00><01>d|}t||<04>||d<04>S)N)
<EFBFBD>jpeg<65>png<6E>gif<69>bmp<6D>tiff<66>webpr=<00>heic<69>avif<69>icozUnknown image format: %s<>save_as_)<01>apply_optimizers)<02>
ValueError<EFBFBD>getattr)r5rE<00>outputrZ<00>operation_namerrr<00>savers z
Image.saverEc
Cs<>t<00>|<02>}|s dSd}z<>t|t<03>rH|j}tdd<03><01>$}t|d<04>r'|<06>|<05><08><00>n |<05> d<05>|<06>|<05>
<EFBFBD><00>|j }Wd<00>n1s@wYd}n\t|t <0C>rotdd<03><01>}|<06>|<01><08><00>|j }Wd<00>n1sgwYd}n5t|d<07>rx|j }n,t|t <0A>r<>|}n$t|t<0E>r<>tdd<03><01>}|<06>|<01>|j }d}Wd<00>n1s<>wY|D]}|<08>|<07>q<>t|d<08>r<>|<01> d<05>t|d <09><02>} |<01>| <09>
<EFBFBD><00>Wd<00>n1s<>wYt|d
<EFBFBD>r<>|<01><11>W|r<>t<12>|<07>dSdS|r<>t<12>|<07>ww) a<>
Runs all available optimizers for the given image format on the given image file.
If the passed image file is a SpooledTemporaryFile or just bytes, we are converting it to a
NamedTemporaryFile to guarantee we can access the file so the optimizers to work on it.
If we get a string, we assume it's a path to a file, and will attempt to load it from
the file system.
NF)<01>delete<74>getvaluerT<>namerH<00>rb<72>truncate)r <00>get_optimizers_for_formatr(r<00>_filerr'<00>writerarH<00>readrbr<00>str<74>bytes<65>processrGrd<00>os<6F>unlink)
r5<00>
image_filerE<00>
optimizers<EFBFBD>named_file_created<65>file<6C>
named_file<EFBFBD> file_path<74> optimizerrDrrr<00>optimize<7A>s\

 

<1C>
 <1C>


 
<1C> 

 <1C>
<02><08> <02>zImage.optimizer)T)r r r <00> classmethodr<00> staticmethodrr"r.r<rGrArr_rirurrrrrs&

  

 <04>
<EFBFBD>rc@s"eZdZdd<02>Zejdd<04><00>ZdS)<06> ImageBuffercCs||_||_dSr)<02>size<7A>data)r5ryrzrrr<00>__init__<5F>s
zImageBuffer.__init__cCs|jSr)ry<00>r5rrr<00>get_size<7A>szImageBuffer.get_sizeN)r r r r{rrr}rrrrrx<00>srxc@<00>,eZdZdZejdd<03><00>Zejdd<05><00>ZdS)<07>RGBImageBuffer<65>RGBcC<00>dS<00>NFrr|rrr<00> has_alpha<68>rzRGBImageBuffer.has_alphacCr<>r<>rr|rrr<00> has_animation<6F>rzRGBImageBuffer.has_animationN<6E>r r r <00>moderrr<>r<>rrrrr<00><00> 
rc@r~)<07>RGBAImageBuffer<65>RGBAcCr<>rrr|rrrr<><00>rzRGBAImageBuffer.has_alphacCr<>r<>rr|rrrr<><00>rzRGBAImageBuffer.has_animationNr<4E>rrrrr<><00>r<>r<>c@s,eZdZedd<02><00>Zedd<04><00>Zdd<06>ZdS)rOcC<00>t<00>)zq
Willow internal name for the image format
ImageFile implementations MUST override this.
<20><01>NotImplementedErrorr|rrr<00> format_name<6D><00>zImageFile.format_namecCr<>)zo
Returns the MIME type of the image file
ImageFile implementations MUST override this.
r<>r|rrr<00> mime_type<70>r<>zImageFile.mime_typecCs
||_dSr)rD)r5rDrrrr{<00>s
zImageFile.__init__N)r r r <00>propertyr<79>r<>r{rrrrrO<00>s 

 rOc@<00>$eZdZedd<02><00>Zedd<04><00>ZdS)<06> JPEGImageFilecCr<>)NrPrr|rrrr<><00>rzJPEGImageFile.format_namecCr<>)Nz
image/jpegrr|rrrr<><00>rzJPEGImageFile.mime_typeN<65>r r r r<>r<>r<>rrrrr<><00><00>

r<>c@r<>)<06> PNGImageFilecCr<>)NrQrr|rrrr<>rzPNGImageFile.format_namecCr<>)Nz image/pngrr|rrrr<>rzPNGImageFile.mime_typeNr<4E>rrrrr<>r<>r<>c@r<>)<06> GIFImageFilecCr<>)NrRrr|rrrr<> rzGIFImageFile.format_namecCr<>)Nz image/gifrr|rrrr<>rzGIFImageFile.mime_typeNr<4E>rrrrr<>
r<>r<>c@r<>)<06> BMPImageFilecCr<>)NrSrr|rrrr<>rzBMPImageFile.format_namecCr<>)Nz image/bmprr|rrrr<>rzBMPImageFile.mime_typeNr<4E>rrrrr<>r<>r<>c@r<>)<06> TIFFImageFilecCr<>)NrTrr|rrrr<>rzTIFFImageFile.format_namecCr<>)Nz
image/tiffrr|rrrr<>#rzTIFFImageFile.mime_typeNr<4E>rrrrr<>r<>r<>c@r<>)<06> WebPImageFilecCr<>)NrUrr|rrrr<>)rzWebPImageFile.format_namecCr<>)Nz
image/webprr|rrrr<>-rzWebPImageFile.mime_typeNr<4E>rrrrr<>(r<>r<>cs&eZdZdZdZd<06>fdd<05> Z<05>ZS)<07> SvgImageFiler=z image/svg+xmlNcs@|dur|<01>d<01>t<01>|<01>|_|<01>d<01>n||_t<04><00>|<01>dS)Nr)rHr<00>parse<73>dom<6F>superr{)r5rDr<><00>r:rrr{6s 
  zSvgImageFile.__init__r)r r r r<>r<>r{<00> __classcell__rrr<>rr<>2sr<>c@r<>)<06> HeicImageFilecCr<>)NrVrr|rrrr<>BrzHeicImageFile.format_namecCr<>)Nz
image/heicrr|rrrr<>FrzHeicImageFile.mime_typeNr<4E>rrrrr<>Ar<>r<>c@r<>)<06> AvifImageFilecCr<>)NrWrr|rrrr<>LrzAvifImageFile.format_namecCr<>)Nz
image/avifrr|rrrr<>PrzAvifImageFile.mime_typeNr<4E>rrrrr<>Kr<>r<>c@seZdZdZdZdS)<04> IcoImageFilerXz image/x-iconN)r r r r<>r<>rrrrr<>Usr<>r=).rlrI<00>ior<00>tempfilerr<00>typingrr?<00>
defusedxmlr<00>filetype.typesr<00> image_typesr <00>IOErrorr
r[rrrxrr<>rOr<>r<>r<>r<>r<>r<>r<>r<>r<>r<><00>Jpeg<65> extension<6F>Png<6E>Gif<69>Bmp<6D>Tiff<66>Webp<62>Heic<69>Avif<69>IcorBrrrr<00><module>sL      %
  















<08>