tencent cloud

Feedback

Image Processing Job APIs

Last updated: 2022-07-28 15:37:32

    Overview

    This document provides an overview of APIs and SDK code samples for image processing.

    API Description
    Submitting image processing job Submits an image processing job.

    Submit Image Processing Job

    Feature description

    This API is used to submit an image processing job.

    Method prototype

    public Guzzle\Service\Resource\Model createMediaPicProcessJobs(array $args = array());
    

    Sample request

    Sample 1. Using a template

    <?php
    require dirname(__FILE__) . '/../vendor/autoload.php';
    $secretId = "SECRETID"; // Replace it with your real `secretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; // Replace it with your real `secretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; // Replace it with your real region information, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\Cos\Client(
      array(
          'region' => $region,
          'schema' => 'https', // Protocol header, which is `http` by default
          'credentials'=> array(
              'secretId'  => $secretId ,
              'secretKey' => $secretKey)));
    try {
      $result = $cosClient->createMediaPicProcessJobs(array(
          'Bucket' => 'examplebucket-125000000', // Bucket name in the format of `BucketName-Appid`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.
          'Tag' => 'PicProcess',
          'QueueId' => 'pcf4d6d9e5e734asd0as8d09as8d09a8d0',
          'Input' => array(
              'Object' => 'test01.png'
          ),
          'Operation' => array(
              'TemplateId' => 't1648745f76c354e8ad8a09sd890ad80a8d',
              'Output' => array(
                  'Region' => $region,
                  'Bucket' => 'examplebucket-125000000', // Bucket name in the format of `BucketName-Appid`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.
                  'Object' => 'picprocess.jpg',
              ),
          ),
          'CallBack' => '',
      ));
      // Request succeeded
      print_r($result);
    } catch (\Exception $e) {
      // Request failed
      echo($e);
    }
    

    Sample 2. Customizing parameters

    <?php
    require dirname(__FILE__) . '/../vendor/autoload.php';
    $secretId = "SECRETID"; // Replace it with your real `secretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; // Replace it with your real `secretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; // Replace it with your real region information, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\Cos\Client(
      array(
          'region' => $region,
          'schema' => 'https', // Protocol header, which is `http` by default
          'credentials'=> array(
              'secretId'  => $secretId ,
              'secretKey' => $secretKey)));
    try {
      $result = $cosClient->createMediaPicProcessJobs(array(
          'Bucket' => 'examplebucket-125000000', // Bucket name in the format of `BucketName-Appid`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.
          'Tag' => 'PicProcess',
          'QueueId' => 'pcf4d6d9e5e734asd0as8d09as8d09a8d0',
          'Input' => array(
              'Object' => 'test01.png'
          ),
          'Operation' => array(
              'PicProcess' => array(
                  'IsPicInfo' => '',
                  'ProcessRule' => '',
              ),
              'Output' => array(
                  'Region' => $region,
                  'Bucket' => 'examplebucket-125000000', // Bucket name in the format of `BucketName-Appid`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.
                  'Object' => 'picprocess.jpg',
              ),
          ),
          'CallBack' => '',
      ));
      // Request succeeded
      print_r($result);
    } catch (\Exception $e) {
      // Request failed
      echo($e);
    }
    

    Parameter description

    Request has the following sub-nodes:

    Node Name (Keyword) Parent Node Description Type Required
    Tag Request Job type: PicProcess String Yes
    Input Request Information of the media file to be processed Container Yes
    Operation Request Operation rule Container Yes
    QueueId Request Queue ID of the image processing job String Yes
    CallBack Request Callback address String No

    Input has the following sub-nodes:

    Node Name (Keyword) Parent Node Description Type Required
    Object Request.Input Media filename String Yes

    Operation has the following sub-nodes:

    Node Name (Keyword) Parent Node Description Type Required
    PicProcess Request.Operation Job type parameter. Same as Request.PicProcess in the image processing template creation API CreateMediaTemplate. Container No
    TemplateId Request.Operation Template ID String No
    Output Request.Operation Result output address Container Yes
    Note:

    TemplateId is used with priority. If TemplateId is unavailable, the corresponding job type parameter is used.

    Output has the following sub-nodes:

    Node Name (Keyword) Parent Node Description Type Required
    Region Request.Operation.Output Bucket region String Yes
    Bucket Request.Operation.Output Result storage bucket String Yes
    Object Request.Operation.Output Output result filename String Yes

    Sample response

    GuzzleHttp\Command\Result Object
    (
      [Body] => GuzzleHttp\Psr7\Stream Object
          (
              [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #88
              [size:GuzzleHttp\Psr7\Stream:private] => 
              [seekable:GuzzleHttp\Psr7\Stream:private] => 1
              [readable:GuzzleHttp\Psr7\Stream:private] => 1
              [writable:GuzzleHttp\Psr7\Stream:private] => 1
              [uri:GuzzleHttp\Psr7\Stream:private] => php://temp
              [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
                  (
                  )
           )
       [RequestId] => NjI2N2E4NTRfNzgwYzAJODIAUSIODUAU3ZQ==
      [ContentType] => application/xml
      [ContentLength] => 795
      [Bucket] => examplebucket-125000000
      [Location] => examplebucket-125000000.ci.ap-guangzhou.myqcloud.com/pic_jobs
      [Response] => Array
          (
              [JobsDetail] => Array
                  (
                      [Code] => Success
                      [CreationTime] => 2022-04-26T16:07:48+0800
                      [EndTime] => -
                      [Input] => Array
                          (
                              [BucketId] => examplebucket-125000000
                              [Object] => test01.png
                              [Region] => ap-guangzhou
                          )
                       [JobId] => cf62e1d50c5sa98d09a8d0a6cf06
                      [Message] => 
                      [Operation] => Array
                          (
                              [Output] => Array
                                  (
                                      [Bucket] => examplebucket-125000000
                                      [Object] => picprocess.jpg
                                      [Region] => ap-guangzhou
                                  )
                               [TemplateId] => t1648745f76asd70as8d90as8d0aa8a09
                              [TemplateName] => PicProcess-1
                          )
                       [QueueId] => pcf4d6d9e5e734d0b82eas90d8a90sdd0
                      [StartTime] => -
                      [State] => Submitted
                      [Tag] => PicProcess
                  )
           )
    )
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support