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

322 lines
20 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD>a<00>@s<>ddlmZddlZddlZddlZddlmZmZmZddl m
Z
m Z m Z ddd
d <0B>Z dedd<11>Zdfdd<17>Z   dgdhd!d"<22>Z  # $didjd.d/<2F>Ze jjfdkd3d4<64>Ze jjfdkd5d6<64>Ze jjdd7fdld:d;<3B>Zdmdnd<d=<3D>Ze jjfdodAdB<64>ZGdCdD<64>dDe<06>Ze jjfdpdFdG<64>ZdqdrdHdI<64>Z dsdtdKdL<64>Ze jjdMd7fdudOdP<64>ZdvdQdR<64>ZdvdSdT<64>Z dvdUdV<64>Z!dvdWdX<64>Z"dwdZd[<5B>Z#dxdyd^d_<64>Z$dd`<60>dzdbdc<64>Z%dS){<7B>)<01> annotationsN)<03>Protocol<6F>Sequence<63>cast<73>)<03>ExifTags<67>Image<67> ImagePalette<74>border<65>int | tuple[int, ...]<5D>return<72>tuple[int, int, int, int]cCs^t|t<01>r!t|<00>dkr|\}}\}}nt|<00>dkr |\}}}}n|}}}}||||fS)N<><00>)<03>
isinstance<EFBFBD>tuple<6C>len)r
<00>left<66>top<6F>right<68>bottom<6F>r<00>N/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/PIL/ImageOps.py<70>_border s
   <02> r<00>color<6F>str | int | tuple[int, ...]<5D>mode<64>strcCs&t|t<01>rddlm}|<02>||<01>}|S)Nr)<01>
ImageColor)rr<00>r<00>getcolor)rrrrrr<00>_color+s
  r!<00>image<67> Image.Image<67>lut<75> list[int]cCs`|jdkr d}t|<02><01>|jdvr&|jdkr!t|<01>dkr!|||}|<00>|<01>Sd|j<00><00>}t|<02><01>)N<>Pzmode P support coming soon)<02>L<>RGBr(<00>znot supported for mode )r<00>NotImplementedErrorr<00>point<6E>OSError)r"r$<00>msgrrr<00>_lut3s

 
 r.F<>cutoff<66>float | tuple[float, float]<5D>ignore<72>int | Sequence[int] | None<6E>mask<73>Image.Image | None<6E> preserve_tone<6E>boolcCs2|r |<00>d<01><01>|<03>}n|<00>|<03>}g}tdt|<05>d<03>D]<5D>}|||d<00>}|dur;t|t<05>r2d||<n |D]} d|| <q4|r<>t|t<06>sF||f}d}
td<03>D]} |
|| }
qLt|
|dd<00>} td<03>D]#} | || krv| || } d|| <n
|| | 8<d} | dkr<>nqct|
|dd<00>} tddd<08>D]#} | || kr<>| || } d|| <n
|| | 8<d} | dkr<>nq<>td<03>D]} || r<>nq<>tddd<08>D]} || r<>nq<>| | kr<>|<06>ttd<03><01><01>qd | | }| |}td<03>D]} t| ||<00>} | dk<00>rd} n| dk<04>r d} |<06> | <09>q<>qt
||<06>S)
a<EFBFBD>
Maximize (normalize) image contrast. This function calculates a
histogram of the input image (or mask region), removes ``cutoff`` percent of the
lightest and darkest pixels from the histogram, and remaps the image
so that the darkest pixel becomes black (0), and the lightest
becomes white (255).
:param image: The image to process.
:param cutoff: The percent to cut off from the histogram on the low and
high ends. Either a tuple of (low, high), or a single
number for both.
:param ignore: The background pixel value (use None for no background).
:param mask: Histogram used in contrast operation is computed using pixels
within the mask. If no mask is given the entire image is used
for histogram computation.
:param preserve_tone: Preserve image tone in Photoshop-like style autocontrast.
.. versionadded:: 8.2.0
:return: An image.
r'rr)N<>dr<00><><00><><EFBFBD><EFBFBD><EFBFBD>g<00>o@) <0B>convert<72> histogram<61>rangerr<00>intr<00>extend<6E>list<73>appendr.)r"r/r1r3r5r;r$<00>layer<65>h<>ix<69>n<>cut<75>lo<6C>hi<68>scale<6C>offsetrrr<00> autocontrastEst




    
<02>  
<02> <02><02> 
 

 <02>
rJr8<00><00>black<63>str | tuple[int, ...]<5D>white<74>mid<69>"str | int | tuple[int, ...] | None<6E>
blackpointr=<00>
whitepoint<EFBFBD>midpointcCs&|jdksJ<00>|durd|kr|krdksJ<00>J<00>nd|kr4|kr4|kr4dks7J<00>J<00>tttt|d<05><02>}tttt|d<05><02>}|durYtttt|d<05><02>nd} g}
g} g} td|<04>D]} |
<EFBFBD>|d<00>| <0B>|d<00>| <0C>|d<00>qf| dur<>td||<00>}|D]A} |
<EFBFBD>|d| |d|dt|<0E><00>| <0B>|d| |d|dt|<0E><00>| <0C>|d| |d|dt|<0E><00>q<>n<EFBFBD>td||<00>}td||<00>}|D]A} |
<EFBFBD>|d| | d|dt|<0F><00>| <0B>|d| | d|dt|<0F><00>| <0C>|d| | d|dt|<0F><00>q<>|D]B} |
<EFBFBD>| d| |d| dt|<10><00>| <0B>| d| |d| dt|<10><00>| <0C>| d| |d| dt|<10><00><00>q"tdd|<00>D]} |
<EFBFBD>|d<00>| <0B>|d<00>| <0C>|d<00><00>ql|<00>d<05>}t ||
| | <00>S) a<>
Colorize grayscale image.
This function calculates a color wedge which maps all black pixels in
the source image to the first color and all white pixels to the
second color. If ``mid`` is specified, it uses three-color mapping.
The ``black`` and ``white`` arguments should be RGB tuples or color names;
optionally you can use three-color mapping by also specifying ``mid``.
Mapping positions for any of the colors can be specified
(e.g. ``blackpoint``), where these parameters are the integer
value corresponding to where the corresponding color should be mapped.
These parameters must have logical order, such that
``blackpoint <= midpoint <= whitepoint`` (if ``mid`` is specified).
:param image: The image to colorize.
:param black: The color to use for black input pixels.
:param white: The color to use for white input pixels.
:param mid: The color to use for midtone input pixels.
:param blackpoint: an int value [0, 255] for the black mapping.
:param whitepoint: an int value [0, 255] for the white mapping.
:param midpoint: an int value [0, 255] for the midtone mapping.
:return: An image.
r'Nrr8r(rrr))
rrrr=r!r<r@rr:r.)r"rLrNrOrQrRrS<00> rgb_black<63> rgb_white<74>rgb_mid<69>red<65>green<65>blue<75>i<> range_map<61>
range_map1<EFBFBD>
range_map2rrr<00>colorize<7A>sf!(0 "<04>"<04>"<06><02> "<04>"<04>"<06>*"<04>.
r^<00>size<7A>tuple[int, int]<5D>methodcCs<>|j|j}|d|d}||krG||kr/t|j|j|d<00>}||dkr.|d|f}nt|j|j|d<00>}||dkrG||df}|j||d<03>S)a<>
Returns a resized version of the image, set to the maximum width and height
within the requested size, while maintaining the original aspect ratio.
:param image: The image to resize.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: Resampling method to use. Default is
:py:attr:`~PIL.Image.Resampling.BICUBIC`.
See :ref:`concept-filters`.
:return: An image.
rr<00><01>resample<6C><04>width<74>height<68>round<6E>resize<7A>r"r_ra<00>im_ratio<69>
dest_ratio<EFBFBD>
new_height<EFBFBD> new_widthrrr<00>contain <00>   <02>  rncCs<>|j|j}|d|d}||krG||kr/t|j|j|d<00>}||dkr.|d|f}nt|j|j|d<00>}||dkrG||df}|j||d<03>S)a<>
Returns a resized version of the image, so that the requested size is
covered, while maintaining the original aspect ratio.
:param image: The image to resize.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: Resampling method to use. Default is
:py:attr:`~PIL.Image.Resampling.BICUBIC`.
See :ref:`concept-filters`.
:return: An image.
rrrbrdrirrr<00>cover+rorp)<02><00>?rq<00> centering<6E>tuple[float, float]c Cs<>t|||<02>}|j|kr|}|St<02>|j||<03>}|jr!|<06>|<05><07><00>|j|dkrEt |d|jt
dt |dd<02><02><00>}|<06> ||df<02>|St |d|j t
dt |dd<02><02><00>}|<06> |d|f<02>|S)at
Returns a resized and padded version of the image, expanded to fill the
requested aspect ratio and size.
:param image: The image to resize and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: Resampling method to use. Default is
:py:attr:`~PIL.Image.Resampling.BICUBIC`.
See :ref:`concept-filters`.
:param color: The background color of the padded image.
:param centering: Control the position of the original image within the
padded version.
(0.5, 0.5) will keep the image centered
(0, 0) will keep the image aligned to the top left
(1, 1) will keep the image aligned to the bottom
right
:return: An image.
rr)rnr_r<00>newr<00>palette<74>
putpalette<EFBFBD>
getpalettererg<00>max<61>min<69>pasterf) r"r_rarrr<00>resized<65>out<75>x<>yrrr<00>padJs 
 <10>&&<26>rcCs6t|<01>\}}}}|<00>|||jd||jd|f<04>S)a/
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes.
.. seealso:: :py:meth:`~PIL.Image.Image.crop`
:param image: The image to crop.
:param border: The number of pixels to remove.
:return: An image.
rr)r<00>cropr_)r"r
rrrrrrrr<>vs &r<><00>factor<6F>floatrccCsL|dkr|<00><00>S|dkrd}t|<03><01>t||j<00>t||j<00>f}|<00>||<02>S)a<>
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image.
:param image: The image to rescale.
:param factor: The expansion factor, as a float.
:param resample: Resampling method to use. Default is
:py:attr:`~PIL.Image.Resampling.BICUBIC`.
See :ref:`concept-filters`.
:returns: An :py:class:`~PIL.Image.Image` object.
rrz!the factor must be greater than 0)<06>copy<70>
ValueErrorrgrerfrh)r"r<>rcr-r_rrrrH<00>s rHc@seZdZdZd dd<07>ZdS)
<EFBFBD>SupportsGetMeshaE
An object that supports the ``getmesh`` method, taking an image as an
argument, and returning a list of tuples. Each tuple contains two tuples,
the source box as a tuple of 4 integers, and a tuple of 8 integers for the
final quadrilateral, in order of top left, bottom left, bottom right, top
right.
r"r#r <00>Ulist[tuple[tuple[int, int, int, int], tuple[int, int, int, int, int, int, int, int]]]cCsdS<00>Nr)<02>selfr"rrr<00>getmesh<73>szSupportsGetMesh.getmeshN)r"r#r r<>)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r<5F>rrrrr<><00>sr<><00>deformercCs|<00>|jtjj|<01>|<00>|<02>S)aL
Deform the image.
:param image: The image to deform.
:param deformer: A deformer object. Any object that implements a
``getmesh`` method can be used.
:param resample: An optional resampling filter. Same values possible as
in the PIL.Image.transform function.
:return: An image.
)<06> transformr_r<00> Transform<72>MESHr<48>)r"r<>rcrrr<00>deform<72>s<04>r<EFBFBD>c Cs<>|jdkr
|<00>d<02>}|<00>|<01>}g}tdt|<02>d<04>D]R}dd<06>|||d<00>D<00>}t|<05>dkr8|<03>ttd<04><01><01>qt<07>t j
|<05>|dd }|sQ|<03>ttd<04><01><01>q|d
}td<04>D]}|<03> ||<00>||||}qYqt ||<03>S) a<>
Equalize the image histogram. This function applies a non-linear
mapping to the input image, in order to create a uniform
distribution of grayscale values in the output image.
:param image: The image to equalize.
:param mask: An optional mask. If given, only the pixels selected by
the mask are included in the analysis.
:return: An image.
r&r(rr)cSsg|]}|r|<01>qSrr)<02>.0<EFBFBD>_frrr<00>
<listcomp><3E><00>zequalize.<locals>.<listcomp>rr9r8r) rr:r;r<rr>r?<00> functools<6C>reduce<63>operator<6F>addr@r.) r"r3rBr$<00>b<>histo<74>steprDrZrrr<00>equalize<7A>s"

  <02>
r<><00>fillc Cs<>t|<01>\}}}}||jd|}||jd|}t||j<03>} |jrBtj|<00><06>d<03>}
t| t<08>rAt | <09>dks<t | <09>dkrA|
<EFBFBD>
| <09>} nd}
t <0B> |j||f| <09>} |
rV| <0B> |
j<04>| <0B>|||f<02>| S)z<>
Add border to the image
:param image: The image to expand.
:param border: Border width, in pixels.
:param fill: Pixel fill value (a color value). Default is 0 (black).
:return: An image.
rr)ru<00>rN)rr_r!rrur rwrrrr rrtrvrz) r"r
r<>rrrrrerfrrur|rrr<00>expand<6E>s  "
<02> r<><00><00>bleedcCs^|\}}d|krdksnd}d|krdksnd}d|kr(dks+nd}||jd||jdf}|jd|dd|jd|ddf}|d|d} |d|d}
| |
krl|d} |d} n| |
kr{|
|d} |d} n
|d} |d|
} |d|d| |} |d|d| |}| || | || f}|j|||d<07>S)a
Returns a resized and cropped version of the image, cropped to the
requested aspect ratio and size.
This function was contributed by Kevin Cazabon.
:param image: The image to resize and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: Resampling method to use. Default is
:py:attr:`~PIL.Image.Resampling.BICUBIC`.
See :ref:`concept-filters`.
:param bleed: Remove a border around the outside of the image from all
four edges. The value is a decimal percentage (use 0.01 for
one percent). The default value is 0 (no border).
Cannot be greater than or equal to 0.5.
:param centering: Control the cropping position. Use (0.5, 0.5) for
center cropping (e.g. if cropping the width, take 50% off
of the left side, and therefore 50% off the right side).
(0.0, 0.0) will crop from the top left corner (i.e. if
cropping the width, take all of the crop off of the right
side, and if cropping the height, take all of it off the
bottom). (1.0, 0.0) will crop from the bottom left
corner, etc. (i.e. if cropping the width, take all of the
crop off the left side, and if cropping the height take
none from the top, and therefore all off the bottom).
:return: An image.
r<>g<00>?rqrrr)<01>box)r_rh)r"r_rar<>rr<00> centering_x<5F> centering_y<5F> bleed_pixels<6C> live_size<7A>live_size_ratio<69> output_ratio<69>
crop_width<EFBFBD> crop_height<68> crop_left<66>crop_topr<70>rrr<00>fit<69>s2(<04>
 
 r<>cC<01>|<00>tjj<03>S)zq
Flip the image vertically (top to bottom).
:param image: The image to flip.
:return: An image.
)<04> transposer<00> Transpose<73>FLIP_TOP_BOTTOM<4F>r"rrr<00>flipZ<00>r<>cCs
|<00>d<01>S)zi
Convert the image to grayscale.
:param image: The image to convert.
:return: An image.
r')r:r<>rrr<00> grayscaleds
r<>cCs.ttddd<02><03>}|jdkr|<00>|<01>St||<01>S)zc
Invert (negate) the image.
:param image: The image to invert.
:return: An image.
r8r9<00>1)r?r<rr+r.)r"r$rrr<00>invertnsr<>cCr<>)zq
Flip image horizontally (left to right).
:param image: The image to mirror.
:return: An image.
)r<>rr<><00>FLIP_LEFT_RIGHTr<54>rrr<00>mirroryr<>r<><00>bitscs2dd|d<00><00>fdd<05>td<06>D<00>}t||<02>S)z<>
Reduce the number of bits for each color channel.
:param image: The image to posterize.
:param bits: The number of bits to keep for each channel (1-8).
:return: An image.
r<00>rcsg|]}|<01>@<00>qSrr)r<>rZ<00>r3rrr<><00>r<>zposterize.<locals>.<listcomp>r))r<r.)r"r<>r$rr<>r<00> posterize<7A>s
r<><00><><00> thresholdcCs>g}td<01>D]}||kr|<02>|<03>q|<02>d|<00>qt||<02>S)z<>
Invert all pixel values above a threshold.
:param image: The image to solarize.
:param threshold: All pixels above this grayscale level are inverted.
:return: An image.
r)r8)r<r@r.)r"r<>r$rZrrr<00>solarize<7A>s   
r<>)<01>in_placer<65>c CsV|<00><00>|<00><01>}|<02>tjjd<01>}tjjtjj tjj
tjj tjj tjj tjjd<02><07>|<03>}|dur<>|<00>|<04>}|rA|j|_d|_|j|_|rE|n|}|<06><01>}tjj|vr<>|tjj=d|jvrc|<07><14>|jd<nd|jvrq|<07><14><00><15>|jd<dD])}||jvr<>dD]} |j|}
t|
t<17>r<>t<18>| d|
<EFBFBD>nt<18>| <09><1A>d |
<EFBFBD>|j|<q|qs|s<>|SdS|s<>|<00><1B>SdS)
a
If an image has an EXIF Orientation tag, other than 1, transpose the image
accordingly, and remove the orientation data.
:param image: The image to transpose.
:param in_place: Boolean. Keyword-only argument.
If ``True``, the original image is modified in-place, and ``None`` is returned.
If ``False`` (default), a new :py:class:`~PIL.Image.Image` object is returned
with the transposition applied. If there is no transposition, a copy of the
image will be returned.
r)rr<>r<00><00><00>r<>N<>exifzRaw profile type exif)zXML:com.adobe.xmp<6D>xmp)ztiff:Orientation="([0-9])"z,<tiff:Orientation>([0-9])</tiff:Orientation>r<00>)<1C>load<61>getexif<69>getr<00>Base<73> Orientationrr<>r<><00>
ROTATE_180r<EFBFBD><00> TRANSPOSE<53>
ROTATE_270<EFBFBD>
TRANSVERSE<EFBFBD> ROTATE_90r<30><00>im<69>pyaccess<73>_size<7A>info<66>tobytes<65>hexrr<00>re<72>sub<75>encoder<65>) r"r<><00>
image_exif<EFBFBD> orientationra<00>transposed_image<67>
exif_imager<EFBFBD><00>key<65>pattern<72>valuerrr<00>exif_transpose<73>sT <04><02>
  




<10>
<EFBFBD><02><04>r<>)r
r r r )rrrrr r )r"r#r$r%r r#)rNNF) r"r#r/r0r1r2r3r4r5r6r r#)Nrr8rK)r"r#rLrMrNrMrOrPrQr=rRr=rSr=r r#)r"r#r_r`rar=r r#) r"r#r_r`rar=rrPrrrsr r#)r)r"r#r
r=r r#)r"r#r<>r<>rcr=r r#)r"r#r<>r<>rcr=r r#r<>)r"r#r3r4r r#)rr)r"r#r
r r<>rr r#) r"r#r_r`rar=r<>r<>rrrsr r#)r"r#r r#)r"r#r<>r=r r#)r<>)r"r#r<>r=r r#)r"r#r<>r6r r4)&<26>
__future__rr<>r<>r<><00>typingrrrrrrr rr!r.rJr^<00>
Resampling<EFBFBD>BICUBICrnrprr<>rHr<><00>BILINEARr<52>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rrrr<00><module>s` 

 <0C>d <0C>h <0C> <0C>" <0C> , <0C> <0C> ! <0C>! <0C>
[