imageenhan-20190930/main.tea (2,965 lines of code) (raw):
/**
*
*/
import Util;
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;
extends OpenApi;
init(config: OpenApi.Config){
super(config);
@endpointRule = 'regional';
checkConfig(config);
@endpoint = getEndpoint('imageenhan', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}
function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
if (!Util.empty(endpoint)) {
return endpoint;
}
if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
return endpointMap[regionId];
}
return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AssessCompositionRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessComposition/AssessComposition1.jpg'),
}
model AssessCompositionAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessComposition/AssessComposition1.jpg'),
}
model AssessCompositionResponseBody = {
data?: {
score?: float(name='Score', example='4.2551436'),
}(name='Data'),
requestId?: string(name='RequestId', example='CCAD9435-AEDB-49E4-BCCC-99B65ECC6693'),
}
model AssessCompositionResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: AssessCompositionResponseBody(name='body'),
}
async function assessCompositionWithOptions(request: AssessCompositionRequest, runtime: Util.RuntimeOptions): AssessCompositionResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AssessComposition',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function assessComposition(request: AssessCompositionRequest): AssessCompositionResponse {
var runtime = new Util.RuntimeOptions{};
return assessCompositionWithOptions(request, runtime);
}
async function assessCompositionAdvance(request: AssessCompositionAdvanceRequest, runtime: Util.RuntimeOptions): AssessCompositionResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var assessCompositionReq = new AssessCompositionRequest{};
OpenApiUtil.convert(request, assessCompositionReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
assessCompositionReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var assessCompositionResp = assessCompositionWithOptions(assessCompositionReq, runtime);
return assessCompositionResp;
}
model AssessExposureRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessExposure/AssessExposure1.jpg'),
}
model AssessExposureAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessExposure/AssessExposure1.jpg'),
}
model AssessExposureResponseBody = {
data?: {
exposure?: float(name='Exposure', example='0.1'),
}(name='Data'),
requestId?: string(name='RequestId', example='4EF3C65B-C3CC-425B-AFB3-2FE6B98C578B'),
}
model AssessExposureResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: AssessExposureResponseBody(name='body'),
}
async function assessExposureWithOptions(request: AssessExposureRequest, runtime: Util.RuntimeOptions): AssessExposureResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AssessExposure',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function assessExposure(request: AssessExposureRequest): AssessExposureResponse {
var runtime = new Util.RuntimeOptions{};
return assessExposureWithOptions(request, runtime);
}
async function assessExposureAdvance(request: AssessExposureAdvanceRequest, runtime: Util.RuntimeOptions): AssessExposureResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var assessExposureReq = new AssessExposureRequest{};
OpenApiUtil.convert(request, assessExposureReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
assessExposureReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var assessExposureResp = assessExposureWithOptions(assessExposureReq, runtime);
return assessExposureResp;
}
model AssessSharpnessRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessSharpness/AssessSharpness1.jpg'),
}
model AssessSharpnessAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/AssessSharpness/AssessSharpness1.jpg'),
}
model AssessSharpnessResponseBody = {
data?: {
sharpness?: float(name='Sharpness', example='0.1'),
}(name='Data'),
requestId?: string(name='RequestId', example='C0B594A1-383E-4F97-A740-0D51CF8E37D2'),
}
model AssessSharpnessResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: AssessSharpnessResponseBody(name='body'),
}
async function assessSharpnessWithOptions(request: AssessSharpnessRequest, runtime: Util.RuntimeOptions): AssessSharpnessResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AssessSharpness',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function assessSharpness(request: AssessSharpnessRequest): AssessSharpnessResponse {
var runtime = new Util.RuntimeOptions{};
return assessSharpnessWithOptions(request, runtime);
}
async function assessSharpnessAdvance(request: AssessSharpnessAdvanceRequest, runtime: Util.RuntimeOptions): AssessSharpnessResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var assessSharpnessReq = new AssessSharpnessRequest{};
OpenApiUtil.convert(request, assessSharpnessReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
assessSharpnessReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var assessSharpnessResp = assessSharpnessWithOptions(assessSharpnessReq, runtime);
return assessSharpnessResp;
}
model ChangeImageSizeRequest {
height?: int32(name='Height', example='600'),
url?: string(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ChangeImageSize/ChangeImageSize5.jpg'),
width?: int32(name='Width', example='800'),
}
model ChangeImageSizeAdvanceRequest {
height?: int32(name='Height', example='600'),
urlObject?: readable(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ChangeImageSize/ChangeImageSize5.jpg'),
width?: int32(name='Width', example='800'),
}
model ChangeImageSizeResponseBody = {
data?: {
retainLocation?: {
height?: int32(name='Height', example='224'),
width?: int32(name='Width', example='298'),
x?: int32(name='X', example='0'),
y?: int32(name='Y', example='0'),
}(name='RetainLocation'),
url?: string(name='Url', example='http://ivpd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/upload/result_filter/2019-11-21/invi_filter_015743271470661000112_NVKmET.png?Expires=1574586347&OSSAccessKeyId=LTAI4FeJ8qKkYn6SrHhQ****&Signature=QqRAiqvyXsVlZ77M8yFc5QKJDE****'),
}(name='Data'),
requestId?: string(name='RequestId', example='2833446F-A431-40EB-A502-6EC9DFEEEEB0'),
}
model ChangeImageSizeResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ChangeImageSizeResponseBody(name='body'),
}
async function changeImageSizeWithOptions(request: ChangeImageSizeRequest, runtime: Util.RuntimeOptions): ChangeImageSizeResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.height)) {
body['Height'] = request.height;
}
if (!Util.isUnset(request.url)) {
body['Url'] = request.url;
}
if (!Util.isUnset(request.width)) {
body['Width'] = request.width;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ChangeImageSize',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function changeImageSize(request: ChangeImageSizeRequest): ChangeImageSizeResponse {
var runtime = new Util.RuntimeOptions{};
return changeImageSizeWithOptions(request, runtime);
}
async function changeImageSizeAdvance(request: ChangeImageSizeAdvanceRequest, runtime: Util.RuntimeOptions): ChangeImageSizeResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var changeImageSizeReq = new ChangeImageSizeRequest{};
OpenApiUtil.convert(request, changeImageSizeReq);
if(!Util.isUnset(request.urlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.urlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
changeImageSizeReq.url = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var changeImageSizeResp = changeImageSizeWithOptions(changeImageSizeReq, runtime);
return changeImageSizeResp;
}
model ColorizeImageRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ColorizeImage/ColorizeImage1.jpg'),
}
model ColorizeImageAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ColorizeImage/ColorizeImage1.jpg'),
}
model ColorizeImageResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-aic-vc-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/face-enhancement/2020_11_26/20201126_182812286268_079260.jpg?Expires=1606388292&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=f71Bx37g%2BGhM%2B6FOXM0EbNL8W4****'),
}(name='Data'),
requestId?: string(name='RequestId', example='124A4B09-68EF-4178-B98D-319089D4268B'),
}
model ColorizeImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ColorizeImageResponseBody(name='body'),
}
async function colorizeImageWithOptions(request: ColorizeImageRequest, runtime: Util.RuntimeOptions): ColorizeImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ColorizeImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function colorizeImage(request: ColorizeImageRequest): ColorizeImageResponse {
var runtime = new Util.RuntimeOptions{};
return colorizeImageWithOptions(request, runtime);
}
async function colorizeImageAdvance(request: ColorizeImageAdvanceRequest, runtime: Util.RuntimeOptions): ColorizeImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var colorizeImageReq = new ColorizeImageRequest{};
OpenApiUtil.convert(request, colorizeImageReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
colorizeImageReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var colorizeImageResp = colorizeImageWithOptions(colorizeImageReq, runtime);
return colorizeImageResp;
}
model EnhanceImageColorRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/EnhanceImageColor/EnhanceImageColor1.jpg'),
mode?: string(name='Mode', example='LogC'),
outputFormat?: string(name='OutputFormat', example='png'),
}
model EnhanceImageColorAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/EnhanceImageColor/EnhanceImageColor1.jpg'),
mode?: string(name='Mode', example='LogC'),
outputFormat?: string(name='OutputFormat', example='png'),
}
model EnhanceImageColorResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/image-recolor/2020-06-23-10/24%3A14-3cf26e84-a5d2-49b0-8332-0e139e20c49e.png?Expires=1592909654&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=fHrYvitvm0qZJ9nrWYa%2Fjd4pQS****'),
}(name='Data'),
requestId?: string(name='RequestId', example='2F306ABD-5BC3-4FA0-89CF-0DED5B3654EB'),
}
model EnhanceImageColorResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: EnhanceImageColorResponseBody(name='body'),
}
async function enhanceImageColorWithOptions(request: EnhanceImageColorRequest, runtime: Util.RuntimeOptions): EnhanceImageColorResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.mode)) {
body['Mode'] = request.mode;
}
if (!Util.isUnset(request.outputFormat)) {
body['OutputFormat'] = request.outputFormat;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'EnhanceImageColor',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function enhanceImageColor(request: EnhanceImageColorRequest): EnhanceImageColorResponse {
var runtime = new Util.RuntimeOptions{};
return enhanceImageColorWithOptions(request, runtime);
}
async function enhanceImageColorAdvance(request: EnhanceImageColorAdvanceRequest, runtime: Util.RuntimeOptions): EnhanceImageColorResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var enhanceImageColorReq = new EnhanceImageColorRequest{};
OpenApiUtil.convert(request, enhanceImageColorReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
enhanceImageColorReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var enhanceImageColorResp = enhanceImageColorWithOptions(enhanceImageColorReq, runtime);
return enhanceImageColorResp;
}
model ErasePersonRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ErasePerson/ErasePerson1.jpg'),
userMask?: string(name='UserMask', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ErasePerson/ErasePerson6.jpg'),
}
model ErasePersonAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ErasePerson/ErasePerson1.jpg'),
userMaskObject?: readable(name='UserMask', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ErasePerson/ErasePerson6.jpg'),
}
model ErasePersonResponseBody = {
data?: {
imageUrl?: string(name='ImageUrl', example='http://algo-app-isr-lab-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/remove-person/2020-10-29_10%3A59%3A21.421276_img19.png?Expires=1603970961&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=9lBakx0r6FOssTEYTcKs5pk8ta****'),
}(name='Data'),
requestId?: string(name='RequestId', example='2FEDA495-9A5D-48B5-8922-98A4FE01D381'),
}
model ErasePersonResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ErasePersonResponseBody(name='body'),
}
async function erasePersonWithOptions(request: ErasePersonRequest, runtime: Util.RuntimeOptions): ErasePersonResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.userMask)) {
body['UserMask'] = request.userMask;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ErasePerson',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function erasePerson(request: ErasePersonRequest): ErasePersonResponse {
var runtime = new Util.RuntimeOptions{};
return erasePersonWithOptions(request, runtime);
}
async function erasePersonAdvance(request: ErasePersonAdvanceRequest, runtime: Util.RuntimeOptions): ErasePersonResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var erasePersonReq = new ErasePersonRequest{};
OpenApiUtil.convert(request, erasePersonReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
erasePersonReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.userMaskObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.userMaskObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
erasePersonReq.userMask = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var erasePersonResp = erasePersonWithOptions(erasePersonReq, runtime);
return erasePersonResp;
}
model ExtendImageStyleRequest {
majorUrl?: string(name='MajorUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ExtendImageStyle/ExtendImageStyle1.jpg'),
styleUrl?: string(name='StyleUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ExtendImageStyle/ExtendImageStyle6.jpg'),
}
model ExtendImageStyleAdvanceRequest {
majorUrlObject?: readable(name='MajorUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ExtendImageStyle/ExtendImageStyle1.jpg'),
styleUrlObject?: readable(name='StyleUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ExtendImageStyle/ExtendImageStyle6.jpg'),
}
model ExtendImageStyleResponseBody = {
data?: {
majorUrl?: string(name='MajorUrl', example='-'),
url?: string(name='Url', example='http://luban-vgd-invi.oss-cn-hangzhou.aliyuncs.com/upload/result_/2019-9-26/invi__015694889247201016812_spCq4n.jpg?Expires=1569492524&OSSAccessKeyId=LTAI4Fc5SVvzUQ19K1Cz****&Signature=uOEP8gKvdgPtDcrXxRz1v37dsT****'),
}(name='Data'),
requestId?: string(name='RequestId', example='F1ABC965-2612-4680-9DE3-B5C77434B9B7'),
}
model ExtendImageStyleResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ExtendImageStyleResponseBody(name='body'),
}
async function extendImageStyleWithOptions(request: ExtendImageStyleRequest, runtime: Util.RuntimeOptions): ExtendImageStyleResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.majorUrl)) {
body['MajorUrl'] = request.majorUrl;
}
if (!Util.isUnset(request.styleUrl)) {
body['StyleUrl'] = request.styleUrl;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ExtendImageStyle',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function extendImageStyle(request: ExtendImageStyleRequest): ExtendImageStyleResponse {
var runtime = new Util.RuntimeOptions{};
return extendImageStyleWithOptions(request, runtime);
}
async function extendImageStyleAdvance(request: ExtendImageStyleAdvanceRequest, runtime: Util.RuntimeOptions): ExtendImageStyleResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var extendImageStyleReq = new ExtendImageStyleRequest{};
OpenApiUtil.convert(request, extendImageStyleReq);
if(!Util.isUnset(request.majorUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.majorUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
extendImageStyleReq.majorUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.styleUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.styleUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
extendImageStyleReq.styleUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var extendImageStyleResp = extendImageStyleWithOptions(extendImageStyleReq, runtime);
return extendImageStyleResp;
}
model GenerateCartoonizedImageRequest {
imageType?: string(name='ImageType', example='girl'),
imageUrl?: string(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/zhangchaorun/1025.jpg'),
index?: string(name='Index', example='0'),
}
model GenerateCartoonizedImageAdvanceRequest {
imageType?: string(name='ImageType', example='girl'),
imageUrlObject?: readable(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/zhangchaorun/1025.jpg'),
index?: string(name='Index', example='0'),
}
model GenerateCartoonizedImageResponseBody = {
data?: {
resultUrl?: string(name='ResultUrl', example='http://vibktprfx-prod-prod-damo-eas-cn-shanghai.oss-cn-shanghai.aliyuncs.com/generative-cartoon/2023-02-02/5a3e5760-ff27-4321-8976-d05656fb716a/20230202_154009511910_pclb0gomva.jpg?Expires=1675325422&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=UmAa7HxeumVkDfrdoL02dtztwS****'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='48f38719-f0c2-4784-a9cc-30df95e393a9'),
}
model GenerateCartoonizedImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GenerateCartoonizedImageResponseBody(name='body'),
}
async function generateCartoonizedImageWithOptions(request: GenerateCartoonizedImageRequest, runtime: Util.RuntimeOptions): GenerateCartoonizedImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageType)) {
body['ImageType'] = request.imageType;
}
if (!Util.isUnset(request.imageUrl)) {
body['ImageUrl'] = request.imageUrl;
}
if (!Util.isUnset(request.index)) {
body['Index'] = request.index;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateCartoonizedImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateCartoonizedImage(request: GenerateCartoonizedImageRequest): GenerateCartoonizedImageResponse {
var runtime = new Util.RuntimeOptions{};
return generateCartoonizedImageWithOptions(request, runtime);
}
async function generateCartoonizedImageAdvance(request: GenerateCartoonizedImageAdvanceRequest, runtime: Util.RuntimeOptions): GenerateCartoonizedImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateCartoonizedImageReq = new GenerateCartoonizedImageRequest{};
OpenApiUtil.convert(request, generateCartoonizedImageReq);
if(!Util.isUnset(request.imageUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateCartoonizedImageReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateCartoonizedImageResp = generateCartoonizedImageWithOptions(generateCartoonizedImageReq, runtime);
return generateCartoonizedImageResp;
}
model GenerateDynamicImageRequest {
operation?: string(name='Operation', example='11'),
url?: string(name='Url', example='https://vigen-invi.oss-cn-shanghai.aliyuncs.com/temp/xl/dynamicPhoto/viapi_test_images/xxxx.jpg'),
}
model GenerateDynamicImageAdvanceRequest {
operation?: string(name='Operation', example='11'),
urlObject?: readable(name='Url', example='https://vigen-invi.oss-cn-shanghai.aliyuncs.com/temp/xl/dynamicPhoto/viapi_test_images/xxxx.jpg'),
}
model GenerateDynamicImageResponseBody = {
data?: {
url?: string(name='Url', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/photo-style-imitation/dynamicPhotoResult/dySkyHair_0d0465eb-b1c9-472a-a7dc-cdff1333f794.avi?Expires=1601196370&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=QejSaTZOR2MB2lVHOUH%2Fj8l3P4****'),
}(name='Data'),
requestId?: string(name='RequestId', example='3C047FB7-AE01-42CF-948F-D57F224620ED'),
}
model GenerateDynamicImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GenerateDynamicImageResponseBody(name='body'),
}
async function generateDynamicImageWithOptions(request: GenerateDynamicImageRequest, runtime: Util.RuntimeOptions): GenerateDynamicImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.operation)) {
body['Operation'] = request.operation;
}
if (!Util.isUnset(request.url)) {
body['Url'] = request.url;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateDynamicImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateDynamicImage(request: GenerateDynamicImageRequest): GenerateDynamicImageResponse {
var runtime = new Util.RuntimeOptions{};
return generateDynamicImageWithOptions(request, runtime);
}
async function generateDynamicImageAdvance(request: GenerateDynamicImageAdvanceRequest, runtime: Util.RuntimeOptions): GenerateDynamicImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateDynamicImageReq = new GenerateDynamicImageRequest{};
OpenApiUtil.convert(request, generateDynamicImageReq);
if(!Util.isUnset(request.urlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.urlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateDynamicImageReq.url = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateDynamicImageResp = generateDynamicImageWithOptions(generateDynamicImageReq, runtime);
return generateDynamicImageResp;
}
model GenerateImageWithTextRequest {
number?: int32(name='Number', example='1'),
resolution?: string(name='Resolution', example='1024*1024'),
text?: string(name='Text'),
}
model GenerateImageWithTextResponseBody = {
data?: {
imageUrls?: [ string ](name='ImageUrls'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='7574ee8f-38a3-4b1e-9280-11c33ab46e51'),
}
model GenerateImageWithTextResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GenerateImageWithTextResponseBody(name='body'),
}
async function generateImageWithTextWithOptions(request: GenerateImageWithTextRequest, runtime: Util.RuntimeOptions): GenerateImageWithTextResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.number)) {
body['Number'] = request.number;
}
if (!Util.isUnset(request.resolution)) {
body['Resolution'] = request.resolution;
}
if (!Util.isUnset(request.text)) {
body['Text'] = request.text;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateImageWithText',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateImageWithText(request: GenerateImageWithTextRequest): GenerateImageWithTextResponse {
var runtime = new Util.RuntimeOptions{};
return generateImageWithTextWithOptions(request, runtime);
}
model GenerateImageWithTextAndImageRequest {
aspectRatioMode?: string(name='AspectRatioMode', example='center_crop'),
number?: int32(name='Number', example='1'),
refImageUrl?: string(name='RefImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/yxrtest/%E6%96%87%E7%94%9F%E5%9B%BE/%E7%9D%A1%E8%8E%B2.jpg"'),
resolution?: string(name='Resolution', example='1024*1024'),
similarity?: float(name='Similarity', example='0.2'),
text?: string(name='Text'),
}
model GenerateImageWithTextAndImageAdvanceRequest {
aspectRatioMode?: string(name='AspectRatioMode', example='center_crop'),
number?: int32(name='Number', example='1'),
refImageUrlObject?: readable(name='RefImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/yxrtest/%E6%96%87%E7%94%9F%E5%9B%BE/%E7%9D%A1%E8%8E%B2.jpg"'),
resolution?: string(name='Resolution', example='1024*1024'),
similarity?: float(name='Similarity', example='0.2'),
text?: string(name='Text'),
}
model GenerateImageWithTextAndImageResponseBody = {
data?: {
imageUrls?: [ string ](name='ImageUrls'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='141fb6d1-28e8-4d93-8165-d966f7092e6a'),
}
model GenerateImageWithTextAndImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GenerateImageWithTextAndImageResponseBody(name='body'),
}
async function generateImageWithTextAndImageWithOptions(request: GenerateImageWithTextAndImageRequest, runtime: Util.RuntimeOptions): GenerateImageWithTextAndImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.aspectRatioMode)) {
body['AspectRatioMode'] = request.aspectRatioMode;
}
if (!Util.isUnset(request.number)) {
body['Number'] = request.number;
}
if (!Util.isUnset(request.refImageUrl)) {
body['RefImageUrl'] = request.refImageUrl;
}
if (!Util.isUnset(request.resolution)) {
body['Resolution'] = request.resolution;
}
if (!Util.isUnset(request.similarity)) {
body['Similarity'] = request.similarity;
}
if (!Util.isUnset(request.text)) {
body['Text'] = request.text;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateImageWithTextAndImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateImageWithTextAndImage(request: GenerateImageWithTextAndImageRequest): GenerateImageWithTextAndImageResponse {
var runtime = new Util.RuntimeOptions{};
return generateImageWithTextAndImageWithOptions(request, runtime);
}
async function generateImageWithTextAndImageAdvance(request: GenerateImageWithTextAndImageAdvanceRequest, runtime: Util.RuntimeOptions): GenerateImageWithTextAndImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateImageWithTextAndImageReq = new GenerateImageWithTextAndImageRequest{};
OpenApiUtil.convert(request, generateImageWithTextAndImageReq);
if(!Util.isUnset(request.refImageUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.refImageUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateImageWithTextAndImageReq.refImageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateImageWithTextAndImageResp = generateImageWithTextAndImageWithOptions(generateImageWithTextAndImageReq, runtime);
return generateImageWithTextAndImageResp;
}
model GenerateSuperResolutionImageRequest {
imageUrl?: string(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/xxx/1025.jpg'),
outputFormat?: string(name='OutputFormat', example='95'),
outputQuality?: int32(name='OutputQuality', example='jpg'),
scale?: int32(name='Scale', example='2'),
userData?: string(name='UserData'),
}
model GenerateSuperResolutionImageAdvanceRequest {
imageUrlObject?: readable(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/xxx/1025.jpg'),
outputFormat?: string(name='OutputFormat', example='95'),
outputQuality?: int32(name='OutputQuality', example='jpg'),
scale?: int32(name='Scale', example='2'),
userData?: string(name='UserData'),
}
model GenerateSuperResolutionImageResponseBody = {
data?: {
resultUrl?: string(name='ResultUrl', example='http://vibktprfx-prod-prod-damo-eas-cn-shanghai.oss-cn-shanghai.aliyuncs.com/diffusion-sr/2023-02-07/d01cede5-28bf-4719-96d9-77198d51c2f2/20230207_150650515242_3dbctnjy5f.jpg?Expires=1675755681&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=4FeDXpp0DilXsHdt7qc%2Ffh3zoC****'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='4ad5c3ef-5ac4-4e1c-b14f-90d939aa73eb'),
}
model GenerateSuperResolutionImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GenerateSuperResolutionImageResponseBody(name='body'),
}
async function generateSuperResolutionImageWithOptions(request: GenerateSuperResolutionImageRequest, runtime: Util.RuntimeOptions): GenerateSuperResolutionImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageUrl)) {
body['ImageUrl'] = request.imageUrl;
}
if (!Util.isUnset(request.outputFormat)) {
body['OutputFormat'] = request.outputFormat;
}
if (!Util.isUnset(request.outputQuality)) {
body['OutputQuality'] = request.outputQuality;
}
if (!Util.isUnset(request.scale)) {
body['Scale'] = request.scale;
}
if (!Util.isUnset(request.userData)) {
body['UserData'] = request.userData;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateSuperResolutionImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateSuperResolutionImage(request: GenerateSuperResolutionImageRequest): GenerateSuperResolutionImageResponse {
var runtime = new Util.RuntimeOptions{};
return generateSuperResolutionImageWithOptions(request, runtime);
}
async function generateSuperResolutionImageAdvance(request: GenerateSuperResolutionImageAdvanceRequest, runtime: Util.RuntimeOptions): GenerateSuperResolutionImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateSuperResolutionImageReq = new GenerateSuperResolutionImageRequest{};
OpenApiUtil.convert(request, generateSuperResolutionImageReq);
if(!Util.isUnset(request.imageUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateSuperResolutionImageReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateSuperResolutionImageResp = generateSuperResolutionImageWithOptions(generateSuperResolutionImageReq, runtime);
return generateSuperResolutionImageResp;
}
model GetAsyncJobResultRequest {
jobId?: string(name='JobId', example='11A898F7-29D7-4AB3-B639-8BBDE671BBD5'),
}
model GetAsyncJobResultResponseBody = {
data?: {
errorCode?: string(name='ErrorCode', example='InvalidParameter'),
errorMessage?: string(name='ErrorMessage', example='paramsIllegal'),
jobId?: string(name='JobId', example='7435839A-5B92-4AA1-B2DE-5B6C98C04DDE'),
result?: string(name='Result', example='http://viapi-cn-shanghai-dha-filter.oss-cn-shanghai.aliyuncs.com/upload/recoloring-hd-2020-06-22-19-39-25-798c9cb57f-v6pj4/2020-6-23/invi_filter_015928997797691000043_tIPX7W.jpg?Expires=1592901579&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=qelgcQJBnzRogPybEPDDrDIjHd****'),
status?: string(name='Status', example='PROCESS_SUCCESS'),
}(name='Data'),
requestId?: string(name='RequestId', example='6B4B827E-1CAA-43CD-BBDF-BB572E035976'),
}
model GetAsyncJobResultResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: GetAsyncJobResultResponseBody(name='body'),
}
async function getAsyncJobResultWithOptions(request: GetAsyncJobResultRequest, runtime: Util.RuntimeOptions): GetAsyncJobResultResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.jobId)) {
body['JobId'] = request.jobId;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GetAsyncJobResult',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function getAsyncJobResult(request: GetAsyncJobResultRequest): GetAsyncJobResultResponse {
var runtime = new Util.RuntimeOptions{};
return getAsyncJobResultWithOptions(request, runtime);
}
model ImageBlindCharacterWatermarkRequest {
functionType?: string(name='FunctionType', example='encode_text'),
originImageURL?: string(name='OriginImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
outputFileType?: string(name='OutputFileType', example='jpg'),
qualityFactor?: int32(name='QualityFactor', example='100'),
text?: string(name='Text'),
watermarkImageURL?: string(name='WatermarkImageURL', example='https://viapi-doc.oss-cn-shanghai.aliyuncs.com/imageenhan/xxxxx.jpg'),
}
model ImageBlindCharacterWatermarkAdvanceRequest {
functionType?: string(name='FunctionType', example='encode_text'),
originImageURLObject?: readable(name='OriginImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
outputFileType?: string(name='OutputFileType', example='jpg'),
qualityFactor?: int32(name='QualityFactor', example='100'),
text?: string(name='Text'),
watermarkImageURLObject?: readable(name='WatermarkImageURL', example='https://viapi-doc.oss-cn-shanghai.aliyuncs.com/imageenhan/xxxxx.jpg'),
}
model ImageBlindCharacterWatermarkResponseBody = {
data?: {
textImageURL?: string(name='TextImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-beauty%2F2020_03_04%2F61f544a1a5004c88a2bf29452db494e9.jpeg?OSSAccessKeyId=LTAI4Fmdm1gQonFLrghJ****&Expires=158340****&Signature=Heet1ivG0xFP3YlO6usvd0pmrH****'),
watermarkImageURL?: string(name='WatermarkImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-beauty%2F2020_03_04%2F61f544a1a5004c88a2bf29452db494e9.jpeg?OSSAccessKeyId=LTAI4Fmdm1gQonFLrghJ****&Expires=158340****&Signature=Heet1ivG0xFP3YlO6usvd0pmrH****'),
}(name='Data'),
requestId?: string(name='RequestId', example='2457E1ED-9C76-4386-B9A2-7E41B7D6E849'),
}
model ImageBlindCharacterWatermarkResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ImageBlindCharacterWatermarkResponseBody(name='body'),
}
async function imageBlindCharacterWatermarkWithOptions(request: ImageBlindCharacterWatermarkRequest, runtime: Util.RuntimeOptions): ImageBlindCharacterWatermarkResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.functionType)) {
body['FunctionType'] = request.functionType;
}
if (!Util.isUnset(request.originImageURL)) {
body['OriginImageURL'] = request.originImageURL;
}
if (!Util.isUnset(request.outputFileType)) {
body['OutputFileType'] = request.outputFileType;
}
if (!Util.isUnset(request.qualityFactor)) {
body['QualityFactor'] = request.qualityFactor;
}
if (!Util.isUnset(request.text)) {
body['Text'] = request.text;
}
if (!Util.isUnset(request.watermarkImageURL)) {
body['WatermarkImageURL'] = request.watermarkImageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ImageBlindCharacterWatermark',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function imageBlindCharacterWatermark(request: ImageBlindCharacterWatermarkRequest): ImageBlindCharacterWatermarkResponse {
var runtime = new Util.RuntimeOptions{};
return imageBlindCharacterWatermarkWithOptions(request, runtime);
}
async function imageBlindCharacterWatermarkAdvance(request: ImageBlindCharacterWatermarkAdvanceRequest, runtime: Util.RuntimeOptions): ImageBlindCharacterWatermarkResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var imageBlindCharacterWatermarkReq = new ImageBlindCharacterWatermarkRequest{};
OpenApiUtil.convert(request, imageBlindCharacterWatermarkReq);
if(!Util.isUnset(request.originImageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.originImageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imageBlindCharacterWatermarkReq.originImageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.watermarkImageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.watermarkImageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imageBlindCharacterWatermarkReq.watermarkImageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var imageBlindCharacterWatermarkResp = imageBlindCharacterWatermarkWithOptions(imageBlindCharacterWatermarkReq, runtime);
return imageBlindCharacterWatermarkResp;
}
model ImageBlindPicWatermarkRequest {
functionType?: string(name='FunctionType', example='encode_pic'),
logoURL?: string(name='LogoURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
originImageURL?: string(name='OriginImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
outputFileType?: string(name='OutputFileType', example='jpg'),
qualityFactor?: int32(name='QualityFactor', example='100'),
watermarkImageURL?: string(name='WatermarkImageURL', example='https://viapi-doc.oss-cn-shanghai.aliyuncs.com/imageenhan/xxxxx.jpg'),
}
model ImageBlindPicWatermarkAdvanceRequest {
functionType?: string(name='FunctionType', example='encode_pic'),
logoURLObject?: readable(name='LogoURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
originImageURLObject?: readable(name='OriginImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxxxx.jpg'),
outputFileType?: string(name='OutputFileType', example='jpg'),
qualityFactor?: int32(name='QualityFactor', example='100'),
watermarkImageURLObject?: readable(name='WatermarkImageURL', example='https://viapi-doc.oss-cn-shanghai.aliyuncs.com/imageenhan/xxxxx.jpg'),
}
model ImageBlindPicWatermarkResponseBody = {
data?: {
logoURL?: string(name='LogoURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-beauty%2F2020_03_04%2F61f544a1a5004c88a2bf29452db494e9.jpeg?OSSAccessKeyId=LTAI4Fmdm1gQonFLrghJ****&Expires=158340****&Signature=Heet1ivG0xFP3YlO6usvd0pmrH****'),
watermarkImageURL?: string(name='WatermarkImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-beauty%2F2020_03_04%2F61f544a1a5004c88a2bf29452db494e9.jpeg?OSSAccessKeyId=LTAI4Fmdm1gQonFLrghJ****&Expires=158340****&Signature=Heet1ivG0xFP3YlO6usvd0pmrH****'),
}(name='Data'),
requestId?: string(name='RequestId', example='DE7869E4-0ACE-4C02-8B98-540B49F49205'),
}
model ImageBlindPicWatermarkResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ImageBlindPicWatermarkResponseBody(name='body'),
}
async function imageBlindPicWatermarkWithOptions(request: ImageBlindPicWatermarkRequest, runtime: Util.RuntimeOptions): ImageBlindPicWatermarkResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.functionType)) {
body['FunctionType'] = request.functionType;
}
if (!Util.isUnset(request.logoURL)) {
body['LogoURL'] = request.logoURL;
}
if (!Util.isUnset(request.originImageURL)) {
body['OriginImageURL'] = request.originImageURL;
}
if (!Util.isUnset(request.outputFileType)) {
body['OutputFileType'] = request.outputFileType;
}
if (!Util.isUnset(request.qualityFactor)) {
body['QualityFactor'] = request.qualityFactor;
}
if (!Util.isUnset(request.watermarkImageURL)) {
body['WatermarkImageURL'] = request.watermarkImageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ImageBlindPicWatermark',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function imageBlindPicWatermark(request: ImageBlindPicWatermarkRequest): ImageBlindPicWatermarkResponse {
var runtime = new Util.RuntimeOptions{};
return imageBlindPicWatermarkWithOptions(request, runtime);
}
async function imageBlindPicWatermarkAdvance(request: ImageBlindPicWatermarkAdvanceRequest, runtime: Util.RuntimeOptions): ImageBlindPicWatermarkResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var imageBlindPicWatermarkReq = new ImageBlindPicWatermarkRequest{};
OpenApiUtil.convert(request, imageBlindPicWatermarkReq);
if(!Util.isUnset(request.logoURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.logoURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imageBlindPicWatermarkReq.logoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.originImageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.originImageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imageBlindPicWatermarkReq.originImageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.watermarkImageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.watermarkImageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imageBlindPicWatermarkReq.watermarkImageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var imageBlindPicWatermarkResp = imageBlindPicWatermarkWithOptions(imageBlindPicWatermarkReq, runtime);
return imageBlindPicWatermarkResp;
}
model ImitatePhotoStyleRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ImitatePhotoStyle/ImitatePhotoStyle1.jpg'),
styleUrl?: string(name='StyleUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ImitatePhotoStyle/ImitatePhotoStyle7.jpg'),
}
model ImitatePhotoStyleAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ImitatePhotoStyle/ImitatePhotoStyle1.jpg'),
styleUrlObject?: readable(name='StyleUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/ImitatePhotoStyle/ImitatePhotoStyle7.jpg'),
}
model ImitatePhotoStyleResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/photo-style-imitation/7c4c0809-5e15-4ca7-84b3-ba16711e3255__5cb220200622-075203.jpg?Expires=1592814125&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=DNhhRFPbMBwpHCEhrLdL%2BBF%2BXs****'),
}(name='Data'),
requestId?: string(name='RequestId', example='A880432B-6D9A-4EF4-B7B7-863F38A930D9'),
}
model ImitatePhotoStyleResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: ImitatePhotoStyleResponseBody(name='body'),
}
async function imitatePhotoStyleWithOptions(request: ImitatePhotoStyleRequest, runtime: Util.RuntimeOptions): ImitatePhotoStyleResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.styleUrl)) {
body['StyleUrl'] = request.styleUrl;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ImitatePhotoStyle',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function imitatePhotoStyle(request: ImitatePhotoStyleRequest): ImitatePhotoStyleResponse {
var runtime = new Util.RuntimeOptions{};
return imitatePhotoStyleWithOptions(request, runtime);
}
async function imitatePhotoStyleAdvance(request: ImitatePhotoStyleAdvanceRequest, runtime: Util.RuntimeOptions): ImitatePhotoStyleResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var imitatePhotoStyleReq = new ImitatePhotoStyleRequest{};
OpenApiUtil.convert(request, imitatePhotoStyleReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imitatePhotoStyleReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.styleUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.styleUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
imitatePhotoStyleReq.styleUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var imitatePhotoStyleResp = imitatePhotoStyleWithOptions(imitatePhotoStyleReq, runtime);
return imitatePhotoStyleResp;
}
model IntelligentCompositionRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/IntelligentComposition/IntelligentComposition3.jpg'),
numBoxes?: int32(name='NumBoxes', example='5'),
}
model IntelligentCompositionAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/IntelligentComposition/IntelligentComposition3.jpg'),
numBoxes?: int32(name='NumBoxes', example='5'),
}
model IntelligentCompositionResponseBody = {
data?: {
elements?: [
{
maxX?: int32(name='MaxX', example='981'),
maxY?: int32(name='MaxY', example='672'),
minX?: int32(name='MinX', example='43'),
minY?: int32(name='MinY', example='96'),
score?: float(name='Score', example='3.6567564'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='C1D52018-D67A-46AD-9AAA-031750A6E770'),
}
model IntelligentCompositionResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: IntelligentCompositionResponseBody(name='body'),
}
async function intelligentCompositionWithOptions(request: IntelligentCompositionRequest, runtime: Util.RuntimeOptions): IntelligentCompositionResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.numBoxes)) {
body['NumBoxes'] = request.numBoxes;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'IntelligentComposition',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function intelligentComposition(request: IntelligentCompositionRequest): IntelligentCompositionResponse {
var runtime = new Util.RuntimeOptions{};
return intelligentCompositionWithOptions(request, runtime);
}
async function intelligentCompositionAdvance(request: IntelligentCompositionAdvanceRequest, runtime: Util.RuntimeOptions): IntelligentCompositionResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var intelligentCompositionReq = new IntelligentCompositionRequest{};
OpenApiUtil.convert(request, intelligentCompositionReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
intelligentCompositionReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var intelligentCompositionResp = intelligentCompositionWithOptions(intelligentCompositionReq, runtime);
return intelligentCompositionResp;
}
model MakeSuperResolutionImageRequest {
mode?: string(name='Mode', example='base'),
outputFormat?: string(name='OutputFormat', example='png'),
outputQuality?: long(name='OutputQuality', example='95'),
upscaleFactor?: long(name='UpscaleFactor', example='2'),
url?: string(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/MakeSuperResolutionImage/MakeSuperResolutionImage5.png'),
}
model MakeSuperResolutionImageAdvanceRequest {
mode?: string(name='Mode', example='base'),
outputFormat?: string(name='OutputFormat', example='png'),
outputQuality?: long(name='OutputQuality', example='95'),
upscaleFactor?: long(name='UpscaleFactor', example='2'),
urlObject?: readable(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/MakeSuperResolutionImage/MakeSuperResolutionImage5.png'),
}
model MakeSuperResolutionImageResponseBody = {
data?: {
url?: string(name='Url', example='http://ivpd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/upload/ai-gateway_prod/ds%253D20191121/sisrx2_157433961551387538.jpg?Expires=1574598816&OSSAccessKeyId=LTAI4FeJ8qKkYn6SrHhQ****&Signature=8phY6dOz4U889nHfHC1g51nwAi****'),
}(name='Data'),
requestId?: string(name='RequestId', example='47DD87F1-D077-499A-8D96-C82F006A6839'),
}
model MakeSuperResolutionImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: MakeSuperResolutionImageResponseBody(name='body'),
}
async function makeSuperResolutionImageWithOptions(request: MakeSuperResolutionImageRequest, runtime: Util.RuntimeOptions): MakeSuperResolutionImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.mode)) {
body['Mode'] = request.mode;
}
if (!Util.isUnset(request.outputFormat)) {
body['OutputFormat'] = request.outputFormat;
}
if (!Util.isUnset(request.outputQuality)) {
body['OutputQuality'] = request.outputQuality;
}
if (!Util.isUnset(request.upscaleFactor)) {
body['UpscaleFactor'] = request.upscaleFactor;
}
if (!Util.isUnset(request.url)) {
body['Url'] = request.url;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'MakeSuperResolutionImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function makeSuperResolutionImage(request: MakeSuperResolutionImageRequest): MakeSuperResolutionImageResponse {
var runtime = new Util.RuntimeOptions{};
return makeSuperResolutionImageWithOptions(request, runtime);
}
async function makeSuperResolutionImageAdvance(request: MakeSuperResolutionImageAdvanceRequest, runtime: Util.RuntimeOptions): MakeSuperResolutionImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var makeSuperResolutionImageReq = new MakeSuperResolutionImageRequest{};
OpenApiUtil.convert(request, makeSuperResolutionImageReq);
if(!Util.isUnset(request.urlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.urlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
makeSuperResolutionImageReq.url = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var makeSuperResolutionImageResp = makeSuperResolutionImageWithOptions(makeSuperResolutionImageReq, runtime);
return makeSuperResolutionImageResp;
}
model RecolorHDImageRequest {
colorCount?: int32(name='ColorCount', example='2'),
colorTemplate?: [
{
color?: string(name='Color', example='[3F6A6B,0A0A6F]'),
}
](name='ColorTemplate', description='1'),
degree?: string(name='Degree', example='0.4'),
mode?: string(name='Mode', example='REF_PIC'),
refUrl?: string(name='RefUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorHDImage/RecolorHDImage-REF_PIC6.jpg'),
url?: string(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorHDImage/RecolorHDImage-auto1.jpg'),
}
model RecolorHDImageAdvanceRequest {
colorCount?: int32(name='ColorCount', example='2'),
colorTemplate?: [
{
color?: string(name='Color', example='[3F6A6B,0A0A6F]'),
}
](name='ColorTemplate', description='1'),
degree?: string(name='Degree', example='0.4'),
mode?: string(name='Mode', example='REF_PIC'),
refUrlObject?: readable(name='RefUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorHDImage/RecolorHDImage-REF_PIC6.jpg'),
urlObject?: readable(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorHDImage/RecolorHDImage-auto1.jpg'),
}
model RecolorHDImageResponseBody = {
data?: {
imageList?: [ string ](name='ImageList', description='1'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='9364CEB1-1C39-489F-B6DB-6E65577429F1'),
}
model RecolorHDImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecolorHDImageResponseBody(name='body'),
}
async function recolorHDImageWithOptions(request: RecolorHDImageRequest, runtime: Util.RuntimeOptions): RecolorHDImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.colorCount)) {
body['ColorCount'] = request.colorCount;
}
if (!Util.isUnset(request.colorTemplate)) {
body['ColorTemplate'] = request.colorTemplate;
}
if (!Util.isUnset(request.degree)) {
body['Degree'] = request.degree;
}
if (!Util.isUnset(request.mode)) {
body['Mode'] = request.mode;
}
if (!Util.isUnset(request.refUrl)) {
body['RefUrl'] = request.refUrl;
}
if (!Util.isUnset(request.url)) {
body['Url'] = request.url;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecolorHDImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recolorHDImage(request: RecolorHDImageRequest): RecolorHDImageResponse {
var runtime = new Util.RuntimeOptions{};
return recolorHDImageWithOptions(request, runtime);
}
async function recolorHDImageAdvance(request: RecolorHDImageAdvanceRequest, runtime: Util.RuntimeOptions): RecolorHDImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recolorHDImageReq = new RecolorHDImageRequest{};
OpenApiUtil.convert(request, recolorHDImageReq);
if(!Util.isUnset(request.refUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.refUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recolorHDImageReq.refUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.urlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.urlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recolorHDImageReq.url = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recolorHDImageResp = recolorHDImageWithOptions(recolorHDImageReq, runtime);
return recolorHDImageResp;
}
model RecolorImageRequest {
colorCount?: int32(name='ColorCount', example='3'),
colorTemplate?: [
{
color?: string(name='Color', example='056A6B'),
}
](name='ColorTemplate', description='1'),
mode?: string(name='Mode', example='TEMPLATE'),
refUrl?: string(name='RefUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorImage/RecolorImage-REF_PIC7.jpg'),
url?: string(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorImage/RecolorImage-REF_PIC1.jpg'),
}
model RecolorImageAdvanceRequest {
colorCount?: int32(name='ColorCount', example='3'),
colorTemplate?: [
{
color?: string(name='Color', example='056A6B'),
}
](name='ColorTemplate', description='1'),
mode?: string(name='Mode', example='TEMPLATE'),
refUrlObject?: readable(name='RefUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorImage/RecolorImage-REF_PIC7.jpg'),
urlObject?: readable(name='Url', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RecolorImage/RecolorImage-REF_PIC1.jpg'),
}
model RecolorImageResponseBody = {
data?: {
imageList?: [ string ](name='ImageList', description='1'),
}(name='Data'),
requestId?: string(name='RequestId', example='3A9BFC5E-3F7C-4D9A-9445-908C6D14AB5B'),
}
model RecolorImageResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecolorImageResponseBody(name='body'),
}
async function recolorImageWithOptions(request: RecolorImageRequest, runtime: Util.RuntimeOptions): RecolorImageResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.colorCount)) {
body['ColorCount'] = request.colorCount;
}
if (!Util.isUnset(request.colorTemplate)) {
body['ColorTemplate'] = request.colorTemplate;
}
if (!Util.isUnset(request.mode)) {
body['Mode'] = request.mode;
}
if (!Util.isUnset(request.refUrl)) {
body['RefUrl'] = request.refUrl;
}
if (!Util.isUnset(request.url)) {
body['Url'] = request.url;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecolorImage',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recolorImage(request: RecolorImageRequest): RecolorImageResponse {
var runtime = new Util.RuntimeOptions{};
return recolorImageWithOptions(request, runtime);
}
async function recolorImageAdvance(request: RecolorImageAdvanceRequest, runtime: Util.RuntimeOptions): RecolorImageResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recolorImageReq = new RecolorImageRequest{};
OpenApiUtil.convert(request, recolorImageReq);
if(!Util.isUnset(request.refUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.refUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recolorImageReq.refUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.urlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.urlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recolorImageReq.url = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recolorImageResp = recolorImageWithOptions(recolorImageReq, runtime);
return recolorImageResp;
}
model RemoveImageSubtitlesRequest {
BH?: float(name='BH', example='0.25'),
BW?: float(name='BW', example='1'),
BX?: float(name='BX', example='0'),
BY?: float(name='BY', example='0.75'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RemoveImageSubtitles/RemoveImageSubtitles1.jpg'),
}
model RemoveImageSubtitlesAdvanceRequest {
BH?: float(name='BH', example='0.25'),
BW?: float(name='BW', example='1'),
BX?: float(name='BX', example='0'),
BY?: float(name='BY', example='0.75'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RemoveImageSubtitles/RemoveImageSubtitles1.jpg'),
}
model RemoveImageSubtitlesResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/image-desubtitle/2020-03-23-08/02%3A50-e8af2ea3-bddc-4ec8-b21c-493ee687465e.jpg?Expires=1584952370&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=qVnfWZJ2QtI9NRWQ410FsEFioq****'),
}(name='Data'),
requestId?: string(name='RequestId', example='939B2103-EE28-4F2D-9773-9A37AD00E5B7'),
}
model RemoveImageSubtitlesResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RemoveImageSubtitlesResponseBody(name='body'),
}
async function removeImageSubtitlesWithOptions(request: RemoveImageSubtitlesRequest, runtime: Util.RuntimeOptions): RemoveImageSubtitlesResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.BH)) {
body['BH'] = request.BH;
}
if (!Util.isUnset(request.BW)) {
body['BW'] = request.BW;
}
if (!Util.isUnset(request.BX)) {
body['BX'] = request.BX;
}
if (!Util.isUnset(request.BY)) {
body['BY'] = request.BY;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RemoveImageSubtitles',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function removeImageSubtitles(request: RemoveImageSubtitlesRequest): RemoveImageSubtitlesResponse {
var runtime = new Util.RuntimeOptions{};
return removeImageSubtitlesWithOptions(request, runtime);
}
async function removeImageSubtitlesAdvance(request: RemoveImageSubtitlesAdvanceRequest, runtime: Util.RuntimeOptions): RemoveImageSubtitlesResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var removeImageSubtitlesReq = new RemoveImageSubtitlesRequest{};
OpenApiUtil.convert(request, removeImageSubtitlesReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
removeImageSubtitlesReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var removeImageSubtitlesResp = removeImageSubtitlesWithOptions(removeImageSubtitlesReq, runtime);
return removeImageSubtitlesResp;
}
model RemoveImageWatermarkRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RemoveImageWatermark/RemoveImageWatermark3.jpg'),
}
model RemoveImageWatermarkAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/imageenhan/RemoveImageWatermark/RemoveImageWatermark3.jpg'),
}
model RemoveImageWatermarkResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/image-delogo/2020-03-27-03/00%3A06-5a6f0a0f-c940-4955-af75-79e8267f1699.jpg?Expires=1585279806&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=R4OC2R5%2Fkw08XYFXmCWjgk7Y9N****'),
}(name='Data'),
requestId?: string(name='RequestId', example='885070A7-E721-4062-99A0-80C0EBBF9406'),
}
model RemoveImageWatermarkResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RemoveImageWatermarkResponseBody(name='body'),
}
async function removeImageWatermarkWithOptions(request: RemoveImageWatermarkRequest, runtime: Util.RuntimeOptions): RemoveImageWatermarkResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RemoveImageWatermark',
version = '2019-09-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function removeImageWatermark(request: RemoveImageWatermarkRequest): RemoveImageWatermarkResponse {
var runtime = new Util.RuntimeOptions{};
return removeImageWatermarkWithOptions(request, runtime);
}
async function removeImageWatermarkAdvance(request: RemoveImageWatermarkAdvanceRequest, runtime: Util.RuntimeOptions): RemoveImageWatermarkResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'imageenhan',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var removeImageWatermarkReq = new RemoveImageWatermarkRequest{};
OpenApiUtil.convert(request, removeImageWatermarkReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
removeImageWatermarkReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var removeImageWatermarkResp = removeImageWatermarkWithOptions(removeImageWatermarkReq, runtime);
return removeImageWatermarkResp;
}