imtools

class lib.imtools.Counter
write(data)
lib.imtools.auto_crop(image)
Crops all transparent or black background from the image :param image: input image :type image: PIL image object :returns: the cropped image :rtype: PIL image object
lib.imtools.calculate_location(horizontal_offset, vertical_offset, horizontal_justification, vertical_justification, canvas_size, image_size)
lib.imtools.checkboard(size, delta=8, fg=(128, 128, 128), bg=(204, 204, 204))
Draw an n x n checkboard
lib.imtools.convert(image, mode, *args, **keyw)

Returns a converted copy of an image

Parameters:
  • image (PIL image object) – input image
  • mode (string) – the new mode
  • args (tuple of values) – extra options
  • keyw (dictionary of options) – extra keyword options
Returns:

the converted image

Return type:

PIL image object

lib.imtools.convert_safe_mode(image)

Converts image into a processing-safe mode.

Parameter:image (PIL image object) – input image
Returns:the converted image
Return type:PIL image object
lib.imtools.example()
lib.imtools.fill_background_color(image, color)
Fills given image with background color
lib.imtools.generate_layer(image, mark, method, horizontal_offset, vertical_offset, horizontal_justification, vertical_justification, orientation, opacity)
lib.imtools.get_alpha(image)

Gets the image alpha band. Can handles P mode images with transpareny. Returns a band with all values set to 255 if no alpha band exists.

Parameter:image (PIL image object) – input image
Returns:alpha as a band
Return type:single band image object
lib.imtools.get_format_data(image, format)
lib.imtools.get_quality(im, size, format, down=0, up=100, delta=1000, options=None)
lib.imtools.get_reverse_transposition(transposition)
lib.imtools.get_size(im, format, **options)
lib.imtools.get_thumb_data(image, format, size=(160, 160))
lib.imtools.has_alpha(image)

Checks if the image has an alpha band. i.e. the image mode is either RGBA or LA. The transparency in the P mode doesn’t count as an alpha band

Parameter:image (PIL image object) – the image to check
Returns:True or False
Return type:boolean
lib.imtools.has_transparency(image)

Checks if the image has transparency. The image has an alpha band or a P mode with transparency.

Parameter:image (PIL image object) – the image to check
Returns:True or False
Return type:boolean
lib.imtools.open_image(x)
lib.imtools.put_alpha(image, alpha)

Copies the given band to the alpha layer of the given image.

Parameters:
  • image (PIL image object) – input image
  • alpha (single band image object) – the alpha band to copy
lib.imtools.reduce_opacity(im, opacity)
Returns an image with reduced opacity if opacity is within [0, 1].
lib.imtools.remove_alpha(image)

Returns a copy of the image after removing the alpha band or transparency

Parameter:image (PIL image object) – input image
Returns:the input image after removing the alpha band or transparency
Return type:PIL image object
lib.imtools.thumb(image, thumb_size=(64, 64), filter=1)
lib.imtools.thumb_from_file(filename, thumb_size=(64, 64), filter=1, write_cache=True, image=None)

Previous topic

gps

Next topic

linux

This Page