Commit c0da3c11 by 庄冰

imghandle.js

parent 8f44edcf
...@@ -335,6 +335,14 @@ class ImageHandleApi extends ApiBase{ ...@@ -335,6 +335,14 @@ class ImageHandleApi extends ApiBase{
//标准商标图样上传(生成黑白商标,调整商标宽高 使其合规) //标准商标图样上传(生成黑白商标,调整商标宽高 使其合规)
async uploadStandardTm(obj){ async uploadStandardTm(obj){
var jpgpath=obj.jpgpath; var jpgpath=obj.jpgpath;
var colorjpgpath = await this.getUidStr(20,62)+".jpg";
colorjpgpath = "zc_color"+colorjpgpath;
if(jpgpath){
var arr = jpgpath.split("/");
if(arr && arr.length>0){
colorjpgpath = arr[arr.length-1];
}
}
// var basename=obj.jpgpath.substring(0,obj.jpgpath.lastIndexOf(".")); // var basename=obj.jpgpath.substring(0,obj.jpgpath.lastIndexOf("."));
var basename=await this.getUidStr(20,62)+".jpg"; var basename=await this.getUidStr(20,62)+".jpg";
var destfile = "/tmp/"+basename; var destfile = "/tmp/"+basename;
...@@ -361,12 +369,13 @@ class ImageHandleApi extends ApiBase{ ...@@ -361,12 +369,13 @@ class ImageHandleApi extends ApiBase{
//合成图像 //合成图像
var comimg=await this._composeImg(scale,maxSize,jpgpathtmp,bkimgpath,comimgpath); var comimg=await this._composeImg(scale,maxSize,jpgpathtmp,bkimgpath,comimgpath);
//上传覆盖元先的路径 //上传覆盖元先的路径
var rtn=await this.ossClient.upfile(jpgpath,comimgpath); var rtn=await this.ossClient.upfile(colorjpgpath,comimgpath);
fs.unlink(jpgpathtmp,function(err){}); fs.unlink(jpgpathtmp,function(err){});
fs.unlink(bkimgpath,function(err){}); fs.unlink(bkimgpath,function(err){});
// fs.unlink(comimgpath,function(err){}); // fs.unlink(comimgpath,function(err){});
var grayimg=await this._grayImg(comimgpath); var grayimg=await this._grayImg(comimgpath);
var blackjpgpath = await this.getUidStr(20,62)+".jpg"; var blackjpgpath = await this.getUidStr(20,62)+".jpg";
blackjpgpath = "zc_black"+blackjpgpath;
var rtn2=await this.ossClient.upfile(blackjpgpath,comimgpath); var rtn2=await this.ossClient.upfile(blackjpgpath,comimgpath);
fs.unlink(comimgpath,function(err){}); fs.unlink(comimgpath,function(err){});
return system.getResult2({"url":rtn.url,"url2":rtn2.url},null); return system.getResult2({"url":rtn.url,"url2":rtn2.url},null);
...@@ -394,28 +403,8 @@ class ImageHandleApi extends ApiBase{ ...@@ -394,28 +403,8 @@ class ImageHandleApi extends ApiBase{
} }
module.exports=ImageHandleApi; module.exports=ImageHandleApi;
// var t=new ImageHandleApi(); // var t=new ImageHandleApi();
//
// t.makeDeleForTM({"url":"http://192.168.18.40:3000/mobile#/products/createwts/10711536633793138"}).then(d=>{ // t.uploadStandardTm({"jpgpath":"https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_picUrl2055157656303330920191117.jpg"}).then(d=>{
// console.log(d); // console.log(d,"dddddddddddddddddddddddddddddddd");
// }); // });
// t.onLineMakeTM("hello","/tmp/a.jpg").then(f=>{
// console.log(f);
// });
// t.adjustTMSize({
// appKey:"wx76a324c5d201d1a4",
// jpgpath:"zc_1158153631265738720187173057387ban4.jpg"
// }).then(d=>{
// console.log(d);
// });
// t.toblack({
// appKey:"wx76a324c5d201d1a4",
// jpgpath:"zc_1158153631265738720187173057387ban4.jpg"
// }).then(d=>{
// console.log(d);
// });
// t._scaleImg("/tmp/a.jpg",400).then(d=>{
// console.log(d);
// });
// t._grayImg("/tmp/b.png").then(d=>{
// console.log(d);
// });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment