Documentation ¶
Index ¶
Constants ¶
const ( // You have no permission to perform this operation. check your CAM policies to make sure that you have the corresponding CAM permissions. AUTHFAILURE_UNAUTHORIZEDOPERATION = "AuthFailure.UnauthorizedOperation" // The generated image failed the review. Please try again. FAILEDOPERATION_GENERATEIMAGEFAILED = "FailedOperation.GenerateImageFailed" // Image decoding failed. FAILEDOPERATION_IMAGEDECODEFAILED = "FailedOperation.ImageDecodeFailed" // Image download error. FAILEDOPERATION_IMAGEDOWNLOADERROR = "FailedOperation.ImageDownloadError" // The image resolution is too high, which exceeds 2000×2000. FAILEDOPERATION_IMAGERESOLUTIONEXCEED = "FailedOperation.ImageResolutionExceed" // The size of the image after base64 encoding cannot exceed 10 MB. FAILEDOPERATION_IMAGESIZEEXCEED = "FailedOperation.ImageSizeExceed" // Internal service error. Please try again. FAILEDOPERATION_INNERERROR = "FailedOperation.InnerError" // The entire request body (usually images) is too large . FAILEDOPERATION_REQUESTENTITYTOOLARGE = "FailedOperation.RequestEntityTooLarge" // The backend service timed out. FAILEDOPERATION_REQUESTTIMEOUT = "FailedOperation.RequestTimeout" // RPC request failed, typically due to algorithm service malfunction. FAILEDOPERATION_RPCFAIL = "FailedOperation.RpcFail" // Internal service error. FAILEDOPERATION_SERVERERROR = "FailedOperation.ServerError" // Unknown error. FAILEDOPERATION_UNKNOWN = "FailedOperation.Unknown" // Invalid parameters. INVALIDPARAMETER_INVALIDPARAMETER = "InvalidParameter.InvalidParameter" // No image is input. INVALIDPARAMETERVALUE_IMAGEEMPTY = "InvalidParameterValue.ImageEmpty" // Parameter or value is invalid. INVALIDPARAMETERVALUE_PARAMETERVALUEERROR = "InvalidParameterValue.ParameterValueError" // 1xx styles cannot be used together with other styles. INVALIDPARAMETERVALUE_STYLECONFLICT = "InvalidParameterValue.StyleConflict" // The input text is too long. Use a shorter one and try again. INVALIDPARAMETERVALUE_TEXTLENGTHEXCEED = "InvalidParameterValue.TextLengthExceed" // The URL format is invalid. INVALIDPARAMETERVALUE_URLILLEGAL = "InvalidParameterValue.UrlIllegal" // The image failed the review because it contains illegal information. OPERATIONDENIED_IMAGEILLEGALDETECTED = "OperationDenied.ImageIllegalDetected" // The text failed the review because it contains illegal information. OPERATIONDENIED_TEXTILLEGALDETECTED = "OperationDenied.TextIllegalDetected" // Too frequent requests REQUESTLIMITEXCEEDED = "RequestLimitExceeded" // Too many tasks are being processed simultaneously. Please try again later. REQUESTLIMITEXCEEDED_JOBNUMEXCEED = "RequestLimitExceeded.JobNumExceed" // The resource is being delivered. RESOURCEUNAVAILABLE_DELIVERING = "ResourceUnavailable.Delivering" // The account is in arrears. RESOURCEUNAVAILABLE_INARREARS = "ResourceUnavailable.InArrears" // Insufficient balance. RESOURCEUNAVAILABLE_LOWBALANCE = "ResourceUnavailable.LowBalance" // The billing status is unknown. Check whether the service has been activated in the console. RESOURCEUNAVAILABLE_NOTEXIST = "ResourceUnavailable.NotExist" // Services for the account has been stopped. RESOURCEUNAVAILABLE_STOPUSING = "ResourceUnavailable.StopUsing" // The billing status is abnormal. RESOURCESSOLDOUT_CHARGESTATUSEXCEPTION = "ResourcesSoldOut.ChargeStatusException" )
const APIVersion = "2022-12-29"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
func NewClient(credential common.CredentialIface, region string, clientProfile *profile.ClientProfile) (client *Client, err error)
func NewClientWithSecretId ¶
Deprecated
func (*Client) ImageToImage ¶
func (c *Client) ImageToImage(request *ImageToImageRequest) (response *ImageToImageResponse, err error)
ImageToImage This API is used to transfer the image style based on the image to image technology. Images with small figures, complex gestures or too many figures are not recommended.
It supports 3 concurrency by default, which means that up to 3 submitted tasks can be processed simultaneously. Subsequent tasks can be processed only after ongoing ones are completed.
error code that may be returned:
AUTHFAILURE_UNAUTHORIZEDOPERATION = "AuthFailure.UnauthorizedOperation" FAILEDOPERATION_GENERATEIMAGEFAILED = "FailedOperation.GenerateImageFailed" FAILEDOPERATION_IMAGEDECODEFAILED = "FailedOperation.ImageDecodeFailed" FAILEDOPERATION_IMAGEDOWNLOADERROR = "FailedOperation.ImageDownloadError" FAILEDOPERATION_IMAGERESOLUTIONEXCEED = "FailedOperation.ImageResolutionExceed" FAILEDOPERATION_IMAGESIZEEXCEED = "FailedOperation.ImageSizeExceed" FAILEDOPERATION_INNERERROR = "FailedOperation.InnerError" FAILEDOPERATION_REQUESTENTITYTOOLARGE = "FailedOperation.RequestEntityTooLarge" FAILEDOPERATION_REQUESTTIMEOUT = "FailedOperation.RequestTimeout" FAILEDOPERATION_RPCFAIL = "FailedOperation.RpcFail" FAILEDOPERATION_SERVERERROR = "FailedOperation.ServerError" FAILEDOPERATION_UNKNOWN = "FailedOperation.Unknown" INVALIDPARAMETER_INVALIDPARAMETER = "InvalidParameter.InvalidParameter" INVALIDPARAMETERVALUE_IMAGEEMPTY = "InvalidParameterValue.ImageEmpty" INVALIDPARAMETERVALUE_PARAMETERVALUEERROR = "InvalidParameterValue.ParameterValueError" INVALIDPARAMETERVALUE_STYLECONFLICT = "InvalidParameterValue.StyleConflict" INVALIDPARAMETERVALUE_TEXTLENGTHEXCEED = "InvalidParameterValue.TextLengthExceed" INVALIDPARAMETERVALUE_URLILLEGAL = "InvalidParameterValue.UrlIllegal" OPERATIONDENIED_IMAGEILLEGALDETECTED = "OperationDenied.ImageIllegalDetected" OPERATIONDENIED_TEXTILLEGALDETECTED = "OperationDenied.TextIllegalDetected" REQUESTLIMITEXCEEDED = "RequestLimitExceeded" REQUESTLIMITEXCEEDED_JOBNUMEXCEED = "RequestLimitExceeded.JobNumExceed" RESOURCEUNAVAILABLE_DELIVERING = "ResourceUnavailable.Delivering" RESOURCEUNAVAILABLE_INARREARS = "ResourceUnavailable.InArrears" RESOURCEUNAVAILABLE_LOWBALANCE = "ResourceUnavailable.LowBalance" RESOURCEUNAVAILABLE_NOTEXIST = "ResourceUnavailable.NotExist" RESOURCEUNAVAILABLE_STOPUSING = "ResourceUnavailable.StopUsing" RESOURCESSOLDOUT_CHARGESTATUSEXCEPTION = "ResourcesSoldOut.ChargeStatusException"
func (*Client) ImageToImageWithContext ¶
func (c *Client) ImageToImageWithContext(ctx context.Context, request *ImageToImageRequest) (response *ImageToImageResponse, err error)
ImageToImage This API is used to transfer the image style based on the image to image technology. Images with small figures, complex gestures or too many figures are not recommended.
It supports 3 concurrency by default, which means that up to 3 submitted tasks can be processed simultaneously. Subsequent tasks can be processed only after ongoing ones are completed.
error code that may be returned:
AUTHFAILURE_UNAUTHORIZEDOPERATION = "AuthFailure.UnauthorizedOperation" FAILEDOPERATION_GENERATEIMAGEFAILED = "FailedOperation.GenerateImageFailed" FAILEDOPERATION_IMAGEDECODEFAILED = "FailedOperation.ImageDecodeFailed" FAILEDOPERATION_IMAGEDOWNLOADERROR = "FailedOperation.ImageDownloadError" FAILEDOPERATION_IMAGERESOLUTIONEXCEED = "FailedOperation.ImageResolutionExceed" FAILEDOPERATION_IMAGESIZEEXCEED = "FailedOperation.ImageSizeExceed" FAILEDOPERATION_INNERERROR = "FailedOperation.InnerError" FAILEDOPERATION_REQUESTENTITYTOOLARGE = "FailedOperation.RequestEntityTooLarge" FAILEDOPERATION_REQUESTTIMEOUT = "FailedOperation.RequestTimeout" FAILEDOPERATION_RPCFAIL = "FailedOperation.RpcFail" FAILEDOPERATION_SERVERERROR = "FailedOperation.ServerError" FAILEDOPERATION_UNKNOWN = "FailedOperation.Unknown" INVALIDPARAMETER_INVALIDPARAMETER = "InvalidParameter.InvalidParameter" INVALIDPARAMETERVALUE_IMAGEEMPTY = "InvalidParameterValue.ImageEmpty" INVALIDPARAMETERVALUE_PARAMETERVALUEERROR = "InvalidParameterValue.ParameterValueError" INVALIDPARAMETERVALUE_STYLECONFLICT = "InvalidParameterValue.StyleConflict" INVALIDPARAMETERVALUE_TEXTLENGTHEXCEED = "InvalidParameterValue.TextLengthExceed" INVALIDPARAMETERVALUE_URLILLEGAL = "InvalidParameterValue.UrlIllegal" OPERATIONDENIED_IMAGEILLEGALDETECTED = "OperationDenied.ImageIllegalDetected" OPERATIONDENIED_TEXTILLEGALDETECTED = "OperationDenied.TextIllegalDetected" REQUESTLIMITEXCEEDED = "RequestLimitExceeded" REQUESTLIMITEXCEEDED_JOBNUMEXCEED = "RequestLimitExceeded.JobNumExceed" RESOURCEUNAVAILABLE_DELIVERING = "ResourceUnavailable.Delivering" RESOURCEUNAVAILABLE_INARREARS = "ResourceUnavailable.InArrears" RESOURCEUNAVAILABLE_LOWBALANCE = "ResourceUnavailable.LowBalance" RESOURCEUNAVAILABLE_NOTEXIST = "ResourceUnavailable.NotExist" RESOURCEUNAVAILABLE_STOPUSING = "ResourceUnavailable.StopUsing" RESOURCESSOLDOUT_CHARGESTATUSEXCEPTION = "ResourcesSoldOut.ChargeStatusException"
type ImageToImageRequest ¶
type ImageToImageRequest struct { *tchttp.BaseRequest // Base64 code of the input mage. // Either the Base64 code or URL must be provided. If both are provided, URL prevails. // Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP. InputImage *string `json:"InputImage,omitnil,omitempty" name:"InputImage"` // URL of the input mage. // Either the Base64 code or URL must be provided. If both are provided, URL prevails. // Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP. InputUrl *string `json:"InputUrl,omitnil,omitempty" name:"InputUrl"` // Text description. // It is used to increase the possibility that the generation result contains the described content. // A maximum of 256 UTF-8 characters are supported. Prompt *string `json:"Prompt,omitnil,omitempty" name:"Prompt"` // Negative text description. // It is used to reduce the possibility that the generation result contains the described content, but such content cannot be completely avoided. // English is recommended. A maximum of 256 UTF-8 characters are supported. NegativePrompt *string `json:"NegativePrompt,omitnil,omitempty" name:"NegativePrompt"` // Image style. // Select the desired style from the [Image Style List](https://intl.cloud.tencent.com/document/product/1668/86250?from_cn_redirect=1) and enter the style number. // It is recommended to use only one style. If no style is specified, 201 (anime style) is used by default. Styles []*string `json:"Styles,omitnil,omitempty" name:"Styles"` // Configurations of the generated image, including the resolution. // Images with the following resolutions can be generated: origin (The resolution is the same as the input image resolution, with the edge resolution of up to 2000. The image will be zoomed out proportionally if the resolution is exceeded.), 768:768 (1:1), 768:1024 (3:4), and 1024:768 (4:3). // If the resolution is not specified, origin is used by default. ResultConfig *ResultConfig `json:"ResultConfig,omitnil,omitempty" name:"ResultConfig"` // Switch indicating whether to add a logo to the generated image. Default value: 1. // 1: add logo // 0: do not add logo // Other values: add logo // It is recommended to use an obvious logo to indicate that the image result is generated by AI. LogoAdd *int64 `json:"LogoAdd,omitnil,omitempty" name:"LogoAdd"` // Logo content settings. // By default, the text "Generated by AI" is added to the bottom right corner of the generated image. You can also use other logo. LogoParam *LogoParam `json:"LogoParam,omitnil,omitempty" name:"LogoParam"` // Generation strength. // The smaller the strength value, the more the generated image resembles the original image. Value range: (0, 1]. If the strength is not specified, the default value of the model is used. // The recommended value range is 0.6 to 0.8. Strength *float64 `json:"Strength,omitnil,omitempty" name:"Strength"` // Image return method (base64 or url). // You can specify only one method. Default value: base64. // The URL is valid for 1 hour. RspImgType *string `json:"RspImgType,omitnil,omitempty" name:"RspImgType"` // Switch indicating whether to enhance image clarity. Default value: 0. // 1: on // 0: off // If the switch is turned on, the image clarity will be enhanced and the generation time will increase. EnhanceImage *int64 `json:"EnhanceImage,omitnil,omitempty" name:"EnhanceImage"` // Maximum number of faces for detail restoration. Value range: 0 - 6. Default value: 0. // If the input value is greater than 0, the value will be used as the maximum number of faces with a small area can be restored in each image. The generation time will increase according to the actual number of faces restored. RestoreFace *int64 `json:"RestoreFace,omitnil,omitempty" name:"RestoreFace"` }
func NewImageToImageRequest ¶
func NewImageToImageRequest() (request *ImageToImageRequest)
func (*ImageToImageRequest) FromJsonString ¶
func (r *ImageToImageRequest) FromJsonString(s string) error
FromJsonString It is highly **NOT** recommended to use this function because it has no param check, nor strict type check
func (*ImageToImageRequest) ToJsonString ¶
func (r *ImageToImageRequest) ToJsonString() string
type ImageToImageRequestParams ¶
type ImageToImageRequestParams struct { // Base64 code of the input mage. // Either the Base64 code or URL must be provided. If both are provided, URL prevails. // Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP. InputImage *string `json:"InputImage,omitnil,omitempty" name:"InputImage"` // URL of the input mage. // Either the Base64 code or URL must be provided. If both are provided, URL prevails. // Image restrictions: The single-edge resolution must be less than 5,000 and greater than 50, and the size after Base64 encoding must be less than 8 MB. Supported formats include JPG, JPEG, PNG, BMP, TIFF and WEBP. InputUrl *string `json:"InputUrl,omitnil,omitempty" name:"InputUrl"` // Text description. // It is used to increase the possibility that the generation result contains the described content. // A maximum of 256 UTF-8 characters are supported. Prompt *string `json:"Prompt,omitnil,omitempty" name:"Prompt"` // Negative text description. // It is used to reduce the possibility that the generation result contains the described content, but such content cannot be completely avoided. // English is recommended. A maximum of 256 UTF-8 characters are supported. NegativePrompt *string `json:"NegativePrompt,omitnil,omitempty" name:"NegativePrompt"` // Image style. // Select the desired style from the [Image Style List](https://intl.cloud.tencent.com/document/product/1668/86250?from_cn_redirect=1) and enter the style number. // It is recommended to use only one style. If no style is specified, 201 (anime style) is used by default. Styles []*string `json:"Styles,omitnil,omitempty" name:"Styles"` // Configurations of the generated image, including the resolution. // Images with the following resolutions can be generated: origin (The resolution is the same as the input image resolution, with the edge resolution of up to 2000. The image will be zoomed out proportionally if the resolution is exceeded.), 768:768 (1:1), 768:1024 (3:4), and 1024:768 (4:3). // If the resolution is not specified, origin is used by default. ResultConfig *ResultConfig `json:"ResultConfig,omitnil,omitempty" name:"ResultConfig"` // Switch indicating whether to add a logo to the generated image. Default value: 1. // 1: add logo // 0: do not add logo // Other values: add logo // It is recommended to use an obvious logo to indicate that the image result is generated by AI. LogoAdd *int64 `json:"LogoAdd,omitnil,omitempty" name:"LogoAdd"` // Logo content settings. // By default, the text "Generated by AI" is added to the bottom right corner of the generated image. You can also use other logo. LogoParam *LogoParam `json:"LogoParam,omitnil,omitempty" name:"LogoParam"` // Generation strength. // The smaller the strength value, the more the generated image resembles the original image. Value range: (0, 1]. If the strength is not specified, the default value of the model is used. // The recommended value range is 0.6 to 0.8. Strength *float64 `json:"Strength,omitnil,omitempty" name:"Strength"` // Image return method (base64 or url). // You can specify only one method. Default value: base64. // The URL is valid for 1 hour. RspImgType *string `json:"RspImgType,omitnil,omitempty" name:"RspImgType"` // Switch indicating whether to enhance image clarity. Default value: 0. // 1: on // 0: off // If the switch is turned on, the image clarity will be enhanced and the generation time will increase. EnhanceImage *int64 `json:"EnhanceImage,omitnil,omitempty" name:"EnhanceImage"` // Maximum number of faces for detail restoration. Value range: 0 - 6. Default value: 0. // If the input value is greater than 0, the value will be used as the maximum number of faces with a small area can be restored in each image. The generation time will increase according to the actual number of faces restored. RestoreFace *int64 `json:"RestoreFace,omitnil,omitempty" name:"RestoreFace"` }
Predefined struct for user
type ImageToImageResponse ¶
type ImageToImageResponse struct { *tchttp.BaseResponse Response *ImageToImageResponseParams `json:"Response"` }
func NewImageToImageResponse ¶
func NewImageToImageResponse() (response *ImageToImageResponse)
func (*ImageToImageResponse) FromJsonString ¶
func (r *ImageToImageResponse) FromJsonString(s string) error
FromJsonString It is highly **NOT** recommended to use this function because it has no param check, nor strict type check
func (*ImageToImageResponse) ToJsonString ¶
func (r *ImageToImageResponse) ToJsonString() string
type ImageToImageResponseParams ¶
type ImageToImageResponseParams struct { // Different content is returned depending on the input parameter RspImgType. // If the value is base64, the Base64 code of the generated image is returned. // If the value is url, the URL of the generated image is returned. The URL is valid for 1 hour. Save it in time. ResultImage *string `json:"ResultImage,omitnil,omitempty" name:"ResultImage"` // The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. RequestId *string `json:"RequestId,omitnil,omitempty" name:"RequestId"` }
Predefined struct for user
type LogoParam ¶
type LogoParam struct { // Logo URL LogoUrl *string `json:"LogoUrl,omitnil,omitempty" name:"LogoUrl"` // Logo Base64 code. Either the Base64 code or URL must be provided. If both are provided, URL prevails. LogoImage *string `json:"LogoImage,omitnil,omitempty" name:"LogoImage"` // Coordinates of the logo image in the generated image. The logo image will be stretched according to the coordinates. LogoRect *LogoRect `json:"LogoRect,omitnil,omitempty" name:"LogoRect"` }
type LogoRect ¶
type LogoRect struct { // X-axis coordinate of the upper left corner X *int64 `json:"X,omitnil,omitempty" name:"X"` // Y-axis coordinate of the upper left corner Y *int64 `json:"Y,omitnil,omitempty" name:"Y"` // Box width Width *int64 `json:"Width,omitnil,omitempty" name:"Width"` // Box height Height *int64 `json:"Height,omitnil,omitempty" name:"Height"` }
type ResultConfig ¶
type ResultConfig struct { // Generated image resolution. // // Images with the following resolutions can be generated: origin (The resolution is the same as the input image resolution, with the edge resolution of up to 2000. The image will be zoomed out proportionally if the resolution is exceeded.), 768:768 (1:1), 768:1024 (3:4), and 1024:768 (4:3). If the resolution is not specified, origin is used by default. The generated image may be cropped if the aspect ratio of the generated image is too different from that of the input image. Resolution *string `json:"Resolution,omitnil,omitempty" name:"Resolution"` }