Modeling Guide

Python2 Image To Message Converter

Converts Python2 Images (message.python.image type) into Messages. This operator converts numpy array into blob of specified format using opencv imencode.

Configuration Parameters

Parameter

Type

Description

from_attributes

boolean

If this value is set to true, the encoding format will be taken from filename attribute. If this attribute is absent, any attribute ending with .filename will be taken. Otherwise, an error will be raised. If the value is false, the image_type will be taken.

Default: true

image_type

string

An image type to be encoded into. The supported types are "JPG", "PNG", "BMP", "PBM", "RAS", "TIF". This only applies if from_attributes is false.

Default: "JPG"

jpg_quality

integer

The quality of the output image from 0 to 100 (the higher is the better). This only applies if from_attributes is false and image_type is JPG.

Default: 95

png_compression

integer

The compression level from 0 to 9. A higher value means a smaller size and longer compression time. This only applies if from_attributes is false and image_type is PNG.

Default: 3

Input

Input

Type

Description

imageIn

message.python.image

The message containing numpy array in the body representing an image to be encoded. Attributes must contain filename, attribute or attribute ending with filename (i.e. storage.filename).

Output

Output

Type

Description

messageOut

message

The message containing an encoded image as a blob in the body. The message contains all the headers that were received and adds new attribute:
encoded_filename (type string)
The updated filename considering new image format.