Styles documentation for an in-depth guide to the image processing behind Picharsso.
DEFAULT_RESAMPLING: str
#The default resampling filter.
RESAMPLING_FILTERS: dict
#A collection of resampling filters. See Pillow's Filters.
BaseDrawer
#An abstract base drawer.
Attributes:
Name | Type | Description |
---|---|---|
height | int | The desired height of the text in characters. |
width | int | The desired width of the text in characters. |
resample | int | The resampling filter. |
format | Type[picharsso.format.BaseFormatter] | The formatter instance. |
__call__(self, image)
special
#Applies processing and formatting on the image
and returns a single string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image | PIL.Image.Image | The subject image. | required |
Returns:
Type | Description |
---|---|
str | The string of text art. |
picharsso/draw/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
__init__(self, height=42, width=0, resample='nearest', **kwargs)
special
#Initialization method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height | Optional[int] | The desired height of the text in characters. | 42 |
width | Optional[int] | The desired width of the text in characters. | 0 |
resample | Optional[str] | The resampling filter. | 'nearest' |
**kwargs | dict | Appropriate keyword arguments. See | {} |
Note
When set as 0
, height
is derived from width
and vice versa. This is done to preserve the aspect ratio of the image.
picharsso/draw/base.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
calculate_size(self, image_size)
#Calculates the size of the image for processing the text matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_size | Tuple[int, int] | The height and width of the subject image. | required |
Returns:
Type | Description |
---|---|
Tuple[int, int] | The size of the image. |
picharsso/draw/base.py
94 95 96 97 98 99 100 101 102 103 | |
process(self, image)
#Converts an image to a matrix of text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image | PIL.Image.Image | The subject image, with | required |
Returns:
Type | Description |
---|---|
numpy.ndarray | The text matrix, with |
picharsso/draw/base.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
set(self, height=None, width=None, resample=None)
#Sets attributes of the drawer instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height | Option[int] | Sets | None |
width | Option[int] | Sets | None |
resample | Option[str] | Sets | None |
Exceptions:
Type | Description |
---|---|
ValueError | If both |
picharsso/draw/base.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |