最近开发了一款百家姓艺术字,直接免费使用,可以用于某鱼进行定制,几元一张,也可以用于某音、某红书、某频号进行引流。废话不多说,直接上代码。
一、接口代码
String surnamesUrl = "https://dashscope.aliyuncs.com/api/v1/services/aigc/wordart/surnames";
Long userId = getLoginUserId();
String aliApiKey = "xxxxxx";
HashMap headMap = new HashMap();
HashMap dataMap = new HashMap();
headMap.put("Content-Type","application/json");
headMap.put("Authorization","Bearer " + aliApiKey);
headMap.put("X-DashScope-Async","enable");
AliSurnamesReq requestBody = new AliSurnamesReq();
AliSurnamesReq.Input input = new AliSurnamesReq.Input();
AliSurnamesReq.Input.Text text = new AliSurnamesReq.Input.Text();
AliSurnamesReq.Parameters parameters = new AliSurnamesReq.Parameters();
String diy = alipParamSurnamesReq.getDiy();
if(!diy.isEmpty() && diy.equals("diy")){
input.setStyle("diy");//当自定义时,必须传diy
if(null != alipParamSurnamesReq.getFontName()){
text.setFont_name(alipParamSurnamesReq.getFontName());
}
if(alipParamSurnamesReq.getTextStrength()>=0.0){
text.setText_strength(alipParamSurnamesReq.getTextStrength());
}
if(null != alipParamSurnamesReq.getImageUrl()){
input.setRef_image_url(alipParamSurnamesReq.getImageUrl());
}
input.setPrompt(alipParamSurnamesReq.getPrompt());
}else{
input.setStyle(alipParamSurnamesReq.getStyle());
}
input.setSurname(alipParamSurnamesReq.getSurname());
if(alipParamSurnamesReq.getNum() != null && alipParamSurnamesReq.getNum()>0){
parameters.setN(alipParamSurnamesReq.getNum());
requestBody.setParameters(parameters);
}
requestBody.setInput(input);
requestBody.setModel("wordart-surnames");
String jsonString = JSONObject.toJSONString(requestBody);
// 现在requestBody对象已经封装了请求体数据
System.out.println(jsonString);
int timeout = 120000;
//百家姓艺术字
String res = HttpClientUtil.doPost(surnamesUrl,headMap,jsonString,timeout);
JSONObject taskObj = JSON.parseObject(res);
JSONObject task = (JSONObject)taskObj.get("output");
String taskId = task.get("task_id").toString();
log.info("百家姓ID为:" + taskId);
二、输出成果
查询生成结果,通过调用https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}即可查询
无论是“赵钱孙李”还是“周吴郑王”,只需输入你的姓氏,AI就能为你量身定制独一无二的艺术字设计。从古典水墨到现代简约,从潮流涂鸦到华丽典雅,多种风格任你选择,30秒即可生成专属姓氏图腾!高清下载后,可用作手机壁纸、朋友圈分享。一键解锁你的姓氏艺术之美,让家族文化焕发新生!体验地址:www.xmgai.cn,生成你的专属姓氏艺术字,看看他们的姓氏会变成什么样子了!
三、生成教程
(1)方式一
直接使用模板,快速生成,如下操作流程,模板有十来种
模板有十来种
(2)方式二(推荐)
输入姓氏,提示词,提示词就是描述整幅画面的风格、内容,展示方式,比如简单的:古风、山水画,或者瀑布、阳光、草原等简单的提示词。最后是选择艺术值,值越小,输出的结果就越艺术,越大,字就越明显。这行方式更加灵活。