Introduction¶
Python package for creating test images. Test images can be created as in memory images or saved in to the filesystem. Package is released under MIT license.
Basic Usage¶
Currently there is only one function create_image.
-
imagefactory.imagefactory.create_image(name='untitled', filetype='png', width=48, height=48, text=None, savedir=None, overwrite=False)[source]¶ Creates in memory images for testing [1]. Bitmap images are created
>>> from imagefactory import create_image >>> create_image() <_io.BytesIO object at ...>
Vector graphic images can be created
>>> from imagefactory import create_image >>> create_image(filetype='svg') <_io.StringIO object at ...>
Parameters: - name (str) –
nameName of the file.name.extIf extension is supplied it overwrites any supplied filetype.
- width (int) – Positive integer
- height (int) – Positive integer
- filetype (str) – Filetype is extension string:
jpeg, png, gif, svg - text (str, optional) –
- Default:
Noneuses{width}x{height} - Otherwise supplied
textstring is used.
- Default:
- savedir (str, optional) –
- Default:
Nonedoesn’t save the image - Otherwise save image to
savedirdirectory
- Default:
- overwrite (Boolean) – Boolean flag for toggling if existing file in the same filepath should be overwritten.
Returns: Image as
BytesIOorStringIOobject. It can be used in same fashion as file object created by opening a file.Return type: BytesIO|StringIO
References
[1] http://wildfish.com/blog/2014/02/27/generating-in-memory-image-for-tests-python/ - name (str) –

