Utils Imaging

inyoka.utils.imaging

This module implements some helper methods to generate thumbnails

copyright:
  1. 2011-2024 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

inyoka.utils.imaging._get_box(img, width, height)
inyoka.utils.imaging.fix_colorspace(image, grayscale=False, replace_alpha=False)

Convert an image to the correct color space.

Parameters:
  • image – an PIL Image instance.

  • grayscale – grayscale the image object.

  • replace_alpha – Replace the transparency layer with a solid color. E.g replace_alpha='#fff'.

inyoka.utils.imaging.get_thumbnail(location, destination, width=None, height=None, force=False)

This function generates a thumbnail for an uploaded image. It uses the media root to cache those thumbnails. A script should delete thumbnails once a month to get rid of unused thumbnails. The wiki will recreate thumbnails automatically.

The return value is None if it cannot generate a thumbnail. Join it with the media root or media URL to get the internal filename. This method generates a PNG thumbnail.

inyoka.utils.imaging.parse_dimensions(dimensions)