jina.types.document.converters

jina.types.document.converters.png_to_buffer(arr, width, height, resize_method)[source]

Convert png to buffer bytes.

Parameters
  • arr (ndarray) – Data representations of the png.

  • width (int) – Width of the png.

  • height (int) – Height of the png.

  • resize_method (str) – Resize methods (e.g. NEAREST, BILINEAR, BICUBIC, and LANCZOS).

Returns

Png in buffer bytes.

jina.types.document.converters.to_image_blob(source, color_axis=- 1)[source]

Convert an image buffer to blob

Parameters
  • source – image bytes buffer

  • color_axis (int) – the axis id of the color channel, -1 indicates the color channel info at the last axis

Return type

ndarray

Returns

image blob

jina.types.document.converters.to_datauri(mimetype, data, charset='utf-8', base64=False, binary=True)[source]

Convert data to data URI.

Parameters
  • mimetype – MIME types (e.g. ‘text/plain’,’image/png’ etc.)

  • data – Data representations.

  • charset (str) – Charset may be any character set registered with IANA

  • base64 (bool) – Used to encode arbitrary octet sequences into a form that satisfies the rules of 7bit. Designed to be efficient for non-text 8 bit and binary data. Sometimes used for text data that frequently uses non-US-ASCII characters.

  • binary (bool) – True if from binary data False for other data (e.g. text)

Returns

URI data

jina.types.document.converters.guess_mime(uri)[source]

Guess the type of a file based on its URL.

Parameters

uri – Data URI.

Returns

MIME type.