|
@ -23,6 +23,7 @@ import com.gxwebsoft.common.core.utils.FileServerUtil; |
|
|
import com.gxwebsoft.common.core.utils.ImageUtil; |
|
|
import com.gxwebsoft.common.core.utils.ImageUtil; |
|
|
import com.gxwebsoft.common.core.web.PageParam; |
|
|
import com.gxwebsoft.common.core.web.PageParam; |
|
|
import com.gxwebsoft.common.core.web.PageResult; |
|
|
import com.gxwebsoft.common.core.web.PageResult; |
|
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.context.annotation.Lazy; |
|
|
import org.springframework.context.annotation.Lazy; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -113,9 +114,33 @@ public class BszxBmServiceImpl extends ServiceImpl<BszxBmMapper, BszxBm> impleme |
|
|
return "https://oss.wsdns.cn/20250908/f8b88d734aac4006a89b9aeb5c3f4f75.png"; |
|
|
return "https://oss.wsdns.cn/20250908/f8b88d734aac4006a89b9aeb5c3f4f75.png"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 百色中学
|
|
|
// Font font = new Font("阿里巴巴普惠体", Font.PLAIN, 40);
|
|
|
// Font font = new Font("阿里巴巴普惠体", Font.PLAIN, 40);
|
|
|
//合成器(指定背景图和输出格式,整个图片的宽高和相关计算依赖于背景图,所以背景图的大小是个基准)
|
|
|
//合成器(指定背景图和输出格式,整个图片的宽高和相关计算依赖于背景图,所以背景图的大小是个基准)
|
|
|
|
|
|
final ImageCombiner combiner = getImageCombiner(item, article); |
|
|
|
|
|
|
|
|
|
|
|
if (!FileUtil.exist(uploadPath + "/poster/" + item.getTenantId() + "/bm")) { |
|
|
|
|
|
FileUtil.mkdir(uploadPath + "/poster/" + item.getTenantId() + "/bm"); |
|
|
|
|
|
} |
|
|
|
|
|
String basePath = "/poster/" + item.getTenantId() + "/bm/big-" + item.getId() + ".jpg"; |
|
|
|
|
|
String smallPath = "/poster/" + item.getTenantId() + "/bm/" + item.getId() + ".jpg"; |
|
|
|
|
|
String filename = uploadPath + basePath; |
|
|
|
|
|
String smallFileName = uploadPath + smallPath; |
|
|
|
|
|
combiner.save(filename); |
|
|
|
|
|
|
|
|
|
|
|
File input = new File(filename); |
|
|
|
|
|
File output = new File(smallFileName); |
|
|
|
|
|
ImageUtil.adjustQuality(input, output, 0.8f); |
|
|
|
|
|
if(input.exists()){ |
|
|
|
|
|
input.delete(); |
|
|
|
|
|
} |
|
|
|
|
|
return fileServer + smallPath + "?r=" + RandomUtil.randomNumbers(4); |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
|
private static ImageCombiner getImageCombiner(BszxBm item, CmsArticle article) throws Exception { |
|
|
ImageCombiner combiner = new ImageCombiner(article.getAddress(), OutputFormat.JPG); |
|
|
ImageCombiner combiner = new ImageCombiner(article.getAddress(), OutputFormat.JPG); |
|
|
//加文本元素:姓名
|
|
|
//加文本元素:姓名
|
|
|
// if (item.getType().equals(0)) {
|
|
|
// if (item.getType().equals(0)) {
|
|
@ -140,25 +165,7 @@ public class BszxBmServiceImpl extends ServiceImpl<BszxBmMapper, BszxBm> impleme |
|
|
// combiner.addImageElement("https://oss.wsdns.cn/20250304/6936b109b09b4919a3498ac5027e728b.png", 600, 1420);
|
|
|
// combiner.addImageElement("https://oss.wsdns.cn/20250304/6936b109b09b4919a3498ac5027e728b.png", 600, 1420);
|
|
|
//执行图片合并
|
|
|
//执行图片合并
|
|
|
combiner.combine(); |
|
|
combiner.combine(); |
|
|
|
|
|
|
|
|
if (!FileUtil.exist(uploadPath + "/file/poster/" + item.getTenantId() + "/bm")) { |
|
|
|
|
|
FileUtil.mkdir(uploadPath + "/file/poster/" + item.getTenantId() + "/bm"); |
|
|
|
|
|
} |
|
|
|
|
|
String basePath = "/poster/" + item.getTenantId() + "/bm/big-" + item.getId() + ".jpg"; |
|
|
|
|
|
String smallPath = "/poster/" + item.getTenantId() + "/bm/" + item.getId() + ".jpg"; |
|
|
|
|
|
String filename = uploadPath + "/file" + basePath; |
|
|
|
|
|
String smallFileName = uploadPath + "/file" + smallPath; |
|
|
|
|
|
combiner.save(filename); |
|
|
|
|
|
|
|
|
|
|
|
File input = new File(filename); |
|
|
|
|
|
File output = new File(smallFileName); |
|
|
|
|
|
ImageUtil.adjustQuality(input, output, 0.8f); |
|
|
|
|
|
if(input.exists()){ |
|
|
|
|
|
input.delete(); |
|
|
|
|
|
} |
|
|
|
|
|
return fileServer + smallPath + "?r=" + RandomUtil.randomNumbers(4); |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
return combiner; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|