老师您好,为什么我的relativepath会直接获取我的图片根路径
来源:4-5 店铺注册之Service层的实现
weixin_慕丝6290347
2022-02-05
public static String generateThumbnail(File thumbnail,String targetAddr) {
String realFileName = getRandomFileName();
String extension = getFileExtension(thumbnail);
makeDirPath(targetAddr);
String relativeAddr = targetAddr + realFileName + extension;
logger.debug("current relativeAddr is" + relativeAddr);
File dest = new File(PathUtil.getImgBasePath()+relativeAddr);
logger.debug("current completeAddr is" + PathUtil.getImgBasePath() + relativeAddr);
try {
Thumbnails.of(thumbnail).size(200, 200)
.watermark(Positions.BOTTOM_RIGHT,ImageIO.read(new File(basePath + "/watermark.jpg")),0.25f)
.outputQuality(0.8).toFile(dest);
Thumbnails.of(thumbnail).size(200, 200)
.watermark(Positions.BOTTOM_RIGHT,ImageIO.read(new File("/watermark.jpg")),0.25f)
.outputQuality(0.8).toFile(dest);
}catch(IOException e) {
logger.error(e.toString());
e.printStackTrace();
}
return relativeAddr;
}
写回答
1回答
-
翔仔
2022-02-05
同学好,可以调试看看你传入的targetAddr是啥,设置断点调试下就知道答案了
022022-02-06
相似问题