tcutility.report package#

Submodules#

tcutility.report.character module#

get_pixel_width(character, font='calibri', font_size=11)[source]#

Get the pixel width of a character for a given font and font-size. For this we need to interpolate the pixel width between two reference values. In the _char_widths.txt file you will find for each font a set of character pixel widths for font-size 1. We then simply multiply the 1-width value by the desired value to get the correct pixel width. See

Parameters:
  • character (str) – the character to get the pixel width for.

  • font (str) – the font family that is used.

  • font_size (float) – the font-size to get the pixel width at.

Return type:

float

text_width(text, font='calibri', font_size=11, mode='pixels')[source]#

Get the width of a string for a given font and font size.

Parameters:
  • text (str) – the object to determine the length for. Will be cast to a string before calculating width.

  • font (str) – the font family that is used.

  • font_size (float) – the font-size to get the pixel width at.

  • mode (str) – the width-mode. Can be ‘excel’ or ‘pixels’.

Return type:

float

Returns:

The width of the text for a certain font and font size. If mode is ‘excel’ we pad it with 8 pixels and then divide by 7.6 (i.e. standard excel char width).

tcutility.report.figure_resizer module#

This module is used for resizing pictures containing molecules.

resize(img_paths, circle_numbers=None, padding=0)[source]#

The main function for this module. Takes a directory d and selected circles and resizes and moves images in order to produce new aligned images.

Parameters:
  • d – the directory to take images from.

  • circle_numbers (Optional[Dict]) – a dictionary containing the image names as keys and circle indices as the values. The new images will be aligned based on these selected circles.

  • padding (Union[str, int, float]) – the amount of padding to add to the new images. If given an integer, it adds padding number of pixels. Alternatively a string consisting of a number and a % sign can be given to add relative padding. E.g. padding=’10%’ will add a 10% padding to the images.

Module contents#