Editor#

class aioEasyPillow.Editor(image: Union[Image, str, BytesIO, Editor, Canvas])#

Editor class. It does all the editing operations.

Parameters

image (Union[Image.Image, str, Editor, Canvas]) – Image or Canvas to edit.

async arc(position: Tuple[float, float], width: float, height: float, start: float, rotation: float, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = 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 (Union[Tuple[int, int, int], str, int], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of fill, by default None

  • stroke_width (float, optional) – Stroke width, by default 1

async bar(position: Tuple[float, float], max_width: Union[int, float], height: Union[int, float], percentage: int = 1, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = None, outline: Optional[Union[Tuple[int, int, int], str, int]] = 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 (Union[Tuple[int, int, int], str, int], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of fill, by default None

  • outline (Union[Tuple[int, int, int], str, int], 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

async blend(image: Union[Image, Editor, Canvas], alpha: float = 0.0, on_top: bool = False) Editor#

Blend image into editor image

Parameters
  • image (Union[Image.Image, Editor, Canvas]) – Image to blend

  • alpha (float, optional) – Alpha amount, by default 0.0

  • on_top (bool, optional) – Places image on top, by default False

async 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

async circle_image() Editor#

Make image circle

async ellipse(position: Tuple[float, float], width: float, height: float, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = None, outline: Optional[Union[Tuple[int, int, int], str, int]] = 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 (Union[Tuple[int, int, int], str, int], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of fill, by default None

  • outline (Union[Tuple[int, int, int], str, int], 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

async multicolor_text(position: Tuple[float, float], texts: List[Text], space_separated: bool = True, align: Literal['left', 'center', 'right'] = 'left', stroke_width: int = 0, stroke_color: Optional[Union[Tuple[int, int, int], str, int]] = None) 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'

  • stroke_width (int, optional) – The optional width of the text stroke, by default 0. Use this as a default if not all of your Text classes have a stroke_width defined.

  • stroke_color (Union[Tuple[int, int, int], str, int], optional) – Color to use for the text stroke. Use this as a default if not all of your Text classes have a stroke_color defined. If there is no stroke_with set in this function nor in the Text class its default is the color from the Text

async paste(image: Union[Image, Editor, Canvas], position: Tuple[float, float] = (0, 0), mask: Optional[Union[Image, Editor]] = None) Editor#

Paste image into editor

Parameters
  • image (Union[Image.Image, Editor, Canvas]) – Image to paste

  • position (Tuple[float, float]) – Position to paste, default is (0,0)

  • mask (Union[Image.Image, Editor]) – An optional mask image, by default None

async polygon(coordinates: list, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = None, outline: Optional[Union[Tuple[int, int, int], str, int]] = None) Editor#

Draw a polygon

Parameters
  • coordinates (list) – Coordinates to draw

  • fill (Union[Tuple[int, int, int], str, int], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of fill, by default None

  • outline (Union[Tuple[int, int, int], str, int], optional) – Outline color, by default None

async rectangle(position: Tuple[float, float], width: float, height: float, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = None, outline: Optional[Union[Tuple[int, int, int], str, int]] = 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 (Union[Tuple[int, int, int], str, int,], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of fill, by default None

  • outline (Union[Tuple[:class:`int, int, int], str, int], optional) – Outline color, by default None

  • stroke_width (float, optional) – Stroke width, by default 1

  • radius (int, optional) – Radius of rectangle, by default 0

async resize(size: Tuple[float, float], crop: bool = False) Editor#

Resize image

Parameters
  • size (Tuple[float, float]) – New Size of image

  • crop (bool, optional) – Crop the image to bypass distortion, by default False

async 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

async rounded_bar(position: Tuple[float, float], width: Union[int, float], height: Union[int, float], percentage: float, fill: Optional[Union[Tuple[int, int, int], str, int]] = None, color: Optional[Union[Tuple[int, int, int], str, int]] = 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 (Union[Tuple[int, int, int], str, int], optional) – Fill color, by default None

  • color (Union[Tuple[int, int, int], str, int], optional) – Alias of color, by default None

  • stroke_width (float, optional) – Stroke width, by default 1

async 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

async save(fp, format: Optional[str] = None, **params)#

Save the image

Parameters
  • fp (str) – File path

  • format (str, optional) – File format, by default None

async show()#

Show the image.

async text(position: Tuple[float, float], text: str, font: Optional[Union[FreeTypeFont, Font]] = None, color: Union[Tuple[int, int, int], str, int] = 'black', align: Literal['left', 'center', 'right'] = 'left', stroke_width: int = 0, stroke_color: Optional[Union[Tuple[int, int, int], str, int]] = None) 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 (Union[Tuple[int, int, int], str, int], optional) – Color of the font, by default 'black'

  • align (Literal['left', 'center', 'right'], optional) – Align text, by default 'left'

  • stroke_width (int, optional) – The optional width of the text stroke, by default 0

  • stroke_color (Union[Tuple[int, int, int], str, int], optional) – Color to use for the text stroke. Default to the color parameter.