Editor¶
- class ez_pil.editor.Editor(_image)¶
Editor class. It does all the editing operations.
- arc(position, width, height, start, rotation, fill=None, color=None, stroke_width=1)¶
Draw arc.
- Parameters:
position (
tuple[float,float]) – Position to draw arcwidth (
float) – Width or archeight (
float) – Height of archstart (
float) – Start position of archrotation (
float) – Rotation in degreefill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of fill, by default Nonestroke_width (
float) – Stroke width, by default 1
- Return type:
- bar(position, max_width, height, percentage=1, fill=None, color=None, outline=None, stroke_width=1, radius=0)¶
Draw a progress bar.
- Parameters:
position (
tuple[int,int]) – Position to draw barmax_width (
int|float) – Max width of the barheight (
int|float) – Height of the barpercentage (
int) – Percentage to fill of the bar, by default 1fill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of fill, by default Noneoutline (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Outline color, by default Nonestroke_width (
float) – Stroke width, by default 1radius (
int) – Radius of the bar, by default 0
- Return type:
- blend(image, alpha=0.0, on_top=False)¶
Blend image into editor image.
- blur(mode='gaussian', amount=1)¶
Blur image.
- Parameters:
mode (
Literal['box','gaussian']) – Blur mode, by default “gaussian”amount (
float) – Amount of blur, by default 1
- Return type:
- close()¶
- ellipse(position, width, height, fill=None, color=None, outline=None, stroke_width=1)¶
Draw an ellipse.
- Parameters:
position (
tuple[float,float]) – Position to draw ellipsewidth (
float) – Width of ellipseheight (
float) – Height of ellipsefill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of fill, by default Noneoutline (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Outline color, by default Nonestroke_width (
float) – Stroke width, by default 1
- Return type:
- property image_bytes: BytesIO¶
Return image bytes.
- multi_text(position, texts, space_separated=True, align='left')¶
Draw multicolor text.
- paste(image, position)¶
Paste image into editor.
- polygon(coordinates, fill=None, color=None, outline=None)¶
Draw a polygon.
- Parameters:
coordinates (
list) – Coordinates to drawfill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of fill, by default Noneoutline (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Outline color, by default None
- Return type:
- rectangle(position, width, height, fill=None, color=None, outline=None, stroke_width=1, radius=0)¶
Draw rectangle into image.
- Parameters:
position (
tuple[float,float]) – Position to draw rectanglewidth (
float) – Width of rectangleheight (
float) – Height of rectanglefill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of fill, by default Noneoutline (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Outline color, by default Nonestroke_width (
float) – Stroke width, by default 1radius (
int) – Radius of rectangle, by default 0
- Return type:
- resize(size, crop=False)¶
Resize image.
- Parameters:
size (
tuple[int,int]) – New Size of imagecrop (
bool) – Crop the image to bypass distortion, by default False
- Return type:
- rotate(deg=0, expand=False)¶
Rotate image.
- Parameters:
deg (
float) – Degrees to rotate, by default 0expand (
bool) – Expand while rotating, by default False
- Return type:
- rounded_bar(position, width, height, percentage, fill=None, color=None, stroke_width=1)¶
Draw a rounded bar.
- Parameters:
position (
tuple[float,float]) – Position to draw rounded barwidth (
int|float) – Width of the barheight (
int|float) – Height of the barpercentage (
float) – Percentage to fill.fill (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Fill color, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int] |None) – Alias of color, by default Nonestroke_width (
float) – Stroke width, by default 1
- Return type:
- rounded_corners(radius=10, offset=2)¶
Make image rounded corners.
- Parameters:
radius (
int) – Radius of roundness, by default 10offset (
int) – Offset pixel while making rounded, by default 2
- Return type:
- save(fp, file_format=None, **params)¶
Save the image.
- Parameters:
fp (
str) – File pathfile_format (
str|None) – File format, by default None
- show()¶
Show the image.
- text(position, text, font=None, color='black', align='left', stroke_width=None, stroke_fill='black')¶
Draw text into image.
- Parameters:
position (
tuple[float,float]) – Position to draw text.text (
str) – Text to drawfont (
FreeTypeFont|Font|None) – Font used for text, by default Nonecolor (
int|str|tuple[int,int,int] |tuple[int,int,int,int]) – Color of the font, by default “black”align (
Literal['left','center','right']) – Align text, by default “left”stroke_width (
int|None) – Whether there should be any stroke. Defaults to None. It represents the width of the said stroke.stroke_fill (
int|str|tuple[int,int,int] |tuple[int,int,int,int]) – Color of the stroke, if any stroke is applied to the text. Defaults to “black”
- Return type: