Написать в техподдержку Позвонить нам
Admin Panel Logout

In this article:

    Submitting Image Processing Requests

    The improve method is used to improve photos.

    Inquiry

    Authorization data is passed in the query string:

    Parameter

    A type

    Value

    oauth_token

    string

    OAuth2 access token (required non-empty)

    oauth_provider

    string

    OAuth2 provider (required non-empty)

    Supported OAuth2 providers:

    ISP

    Oauth_provider value

    Getting a token

    MCS

    mcs

    https://mcs.mail.ru/

    Request parameters are passed in JSON format in the request body with name = "meta":

    Parameter

    A type

    Value

    mode

    [] string

    types of objects to search for in the transferred images (required non-empty)

    images

    [] image_meta

    metadata of uploaded images (required non-empty)

    rfactor

    int

    resolution increase factor, can be either 2 or 4 (required non-empty for resolution mode)

    ftype

    string

    image type, "art" or "photo" (required non-empty for resolution mode)

    Possible mode values:

    Parameter

    Value

    improve

    photo recovery

    resolution

    increase in resolution

    image_meta

    Parameter

    A type

    Value

    name

    string

    filenames to match files in request and response (required non-empty)

    Images are passed in the request body, the values of the name field must match those passed in images.

    The maximum number of images in one request is 48. The maximum size of each image should not exceed 8MB.


    Example request:

    POST / api / v1 / photo / improve /? Oauth_provider = mr & oauth_token = 123 HTTP / 1.1

    Content-Type: multipart / form-data; boundary = ---- WebKitFormBoundaryfCqTBHeLZlsicvMp

    ------ WebKitFormBoundaryfCqTBHeLZlsicvMp
    Content-Disposition: form-data; name = "file_0"; filename = ""
    Content-Type: image / jpeg

    000000000000000000000000000
    000000000000000000000000000
    000000000000000000000000000
    ------ WebKitFormBoundaryfCqTBHeLZlsicvMp
    Content-Disposition: form-data; name = "file_1"; filename = ""
    Content-Type: image / jpeg

    111111111111111111111111111
    111111111111111111111111111
    111111111111111111111111111
    ------ WebKitFormBoundaryfCqTBHeLZlsicvMp
    Content-Disposition: form-data; name = "meta"

    {"images": [{"name": "file_0"}, {"name": "file_1"}], "mode": ["improve", "resolution"]}
    ------ WebKitFormBoundaryfCqTBHeLZlsicvMp--

    Answer

    Parameter

    A type

    Value

    status

    int

    200 if successful, otherwise the error description will be in the body

    body

    string | response

    response body

    response

    Parameter

    A type

    Value

    improve

    [] improve_object

    array of responses for improve mode

    resolution

    [] resolution_object

    array of responses for resolution mode

    improve_object

    Parameter

    A type

    Value

    status

    enum

    execution result

    error

    string

    textual description of the error (optional)

    name

    string

    filename to match files in request and response

    improved

    string

    jpeg picture of a photo with corrected defects (base64)

    The field may be absent or empty if the algorithm thinks the photo does not make sense

    restore (she is already good)

    colorized_improved

    string

    jpeg picture of a photo with corrected defects and restored color (base64)

    The field may be absent or empty if the algorithm thinks the photo does not make sense

    restore and paint over

    colorized

    string

    jpeg picture of the photo with the recovered color (base64)

    bw

    bool

    true - the algorithm considers that it was given a black and white photo as input

    false - the algorithm considers that it was given a color photo as input

    resolution_object

    Parameter

    A type

    Value

    status

    enum

    execution result

    error

    string

    textual description of the error (optional)

    name

    string

    filename to match files in request and response

    resolved

    string

    jpeg picture of the photo with increased resolution (base64)

    status

    Parameter

    Value

    0

    successfully

    1

    permanent error

    2

    temporary error

    Sample response:

     {
    "status": 200,
    "body": {
    "status": 0,
    "improve": [
    {
    "status": 0,
    "name": "file_0",
    "improved": "base64",
    "colorized_improved": "base64",
    "colorized": "base64",
    "bw": true
    }
    ],
    "resolution": [
    {
    "status": 0,
    "name": "file_0",
    "resolved": "base64"
    }
    ]
    }
    }

    An example of a response when the request failed

     {
    "status": 500,
    "body": "Internal Server Error",
    "htmlencoded": false,
    "last_modified": 0
    }

    An example of an answer if the image could not be loaded:

     {
    "status": 200,
    "body": {
    "improve": [
    {
    "status": 2,
    "error": "unable decode input image",
    "name": "file_0"
    }
    ]
    },
    "htmlencoded": false,
    "last_modified": 0
    }

    An example of a curl request:

     curl -v "https://smarty.mail.ru/api/v1/photo/improve?oauth_provider=mcs&oauth_token=token" -F file_0=@test.jpeg -F meta = '{"images": [{"name ":" file_0 "}]," mode ": [" resolution "," improve "]," rfactor ": 4," rtype ":" art "} '

    Was this article helpful?