Editor#
- class easy_pil.editor.Editor(_image: Image | str | BytesIO | Editor | Canvas | Path)#
Editor class. It does all the editing operations.
- arc(position: Tuple[float, float], width: float, height: float, start: float, rotation: float, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, stroke_width: float = 1) Editor #
Draw arc
- Parameters:
position (Tuple[float, float]) – Position to draw arc
width (float) – Width or arc
height (float) – Height of arch
start (float) – Start position of arch
rotation (float) – Rotation in degree
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of fill, by default None
stroke_width (float, optional) – Stroke width, by default 1
- bar(position: Tuple[float, float], max_width: int | float, height: int | float, percentage: int = 1, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, outline: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, stroke_width: float = 1, radius: int = 0) Editor #
Draw a progress bar
- Parameters:
position (Tuple[float, float]) – Position to draw bar
max_width (Union[int, float]) – Max width of the bar
height (Union[int, float]) – Height of the bar
percentage (int, optional) – Percentage to fill of the bar, by default 1
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of fill, by default None
outline (Color, optional) – Outline color, by default None
stroke_width (float, optional) – Stroke width, by default 1
radius (int, optional) – Radius of the bar, by default 0
- blend(image: Image | Editor | Canvas, alpha: float = 0.0, on_top: bool = False) Editor #
Blend image into editor image
- blur(mode: Literal['box', 'gaussian'] = 'gaussian', amount: float = 1) Editor #
Blur image
- Parameters:
mode (Literal["box", "gaussian"], optional) – Blur mode, by default “gaussian”
amount (float, optional) – Amount of blur, by default 1
- ellipse(position: Tuple[float, float], width: float, height: float, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, outline: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, stroke_width: float = 1) Editor #
Draw an ellipse
- Parameters:
position (Tuple[float, float]) – Position to draw ellipse
width (float) – Width of ellipse
height (float) – Height of ellipse
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of fill, by default None
outline (Color, optional) – Outline color, by default None
stroke_width (float, optional) – Stroke width, by default 1
- property image_bytes: BytesIO#
Return image bytes
- Returns:
Bytes from the image of Editor
- Return type:
BytesIO
- multi_text(position: Tuple[float, float], texts: List[Text], space_separated: bool = True, align: Literal['left', 'center', 'right'] = 'left') Editor #
Draw multicolor text
- Parameters:
position (Tuple[float, float]) – Position to draw text
texts (List[Text]) – List of texts
space_separated (bool, optional) – Separate texts with space, by default True
align (Literal["left", "center", "right"], optional) – Align texts, by default “left”
- polygon(coordinates: list, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, outline: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None) Editor #
Draw a polygon
- Parameters:
coordinates (list) – Coordinates to draw
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of fill, by default None
outline (Color, optional) – Outline color, by default None
- rectangle(position: Tuple[float, float], width: float, height: float, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, outline: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, stroke_width: float = 1, radius: int = 0) Editor #
Draw rectangle into image
- Parameters:
position (Tuple[float, float]) – Position to draw rectangle
width (float) – Width of rectangle
height (float) – Height of rectangle
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of fill, by default None
outline (Color, optional) – Outline color, by default None
stroke_width (float, optional) – Stroke width, by default 1
radius (int, optional) – Radius of rectangle, by default 0
- resize(size: Tuple[int, int], crop=False) Editor #
Resize image
- Parameters:
size (Tuple[int, int]) – New Size of image
crop (bool, optional) – Crop the image to bypass distortion, by default False
- rotate(deg: float = 0, expand: bool = False) Editor #
Rotate image
- Parameters:
deg (float, optional) – Degrees to rotate, by default 0
expand (bool, optional) – Expand while rotating, by default False
- rounded_bar(position: Tuple[float, float], width: int | float, height: int | float, percentage: float, fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None = None, stroke_width: float = 1) Editor #
Draw a rounded bar
- Parameters:
position (Tuple[float, float]) – Position to draw rounded bar
width (Union[int, float]) – Width of the bar
height (Union[int, float]) – Height of the bar
percentage (float) – Percentage to fill.
fill (Color, optional) – Fill color, by default None
color (Color, optional) – Alias of color, by default None
stroke_width (float, optional) – Stroke width, by default 1
- rounded_corners(radius: int = 10, offset: int = 2) Editor #
Make image rounded corners
- Parameters:
radius (int, optional) – Radius of roundness, by default 10
offset (int, optional) – Offset pixel while making rounded, by default 2
- save(fp, file_format: str | None = None, **params)#
Save the image
- Parameters:
fp (str) – File path
file_format (str, optional) – File format, by default None
- show()#
Show the image.
- text(position: Tuple[float, float], text: str, font: FreeTypeFont | Font | None = None, color: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] = 'black', align: Literal['left', 'center', 'right'] = 'left', stroke_width: int | None = None, stroke_fill: int | str | Tuple[int, int, int] | Tuple[int, int, int, int] = 'black') Editor #
Draw text into image
- Parameters:
position (Tuple[float, float]) – Position to draw text.
text (str) – Text to draw
font (Union[ImageFont.FreeTypeFont, Font], optional) – Font used for text, by default None
color (Color, optional) – Color of the font, by default “black”
align (Literal["left", "center", "right"], optional) – Align text, by default “left”
stroke_width (int, optional) – Whether there should be any stroke. Defaults to None. It represents the width of the said stroke.
stroke_fill (Color, optional) – Color of the stroke, if any stroke is applied to the text. Defaults to “black”