|
@@ -163,8 +163,8 @@ public class ImageClassificationFileController extends BladeController {
|
|
|
//需要删除的本地文件集合
|
|
|
List<String> removeList = new ArrayList<>();
|
|
|
|
|
|
- // 压缩到小于指定文件大小200kb
|
|
|
- double targetSize = 200 * 1024;
|
|
|
+ // 压缩到小于指定文件大小500kb
|
|
|
+ double targetSize = 500 * 1024;
|
|
|
|
|
|
for (ImageClassificationFile file : fileResult) {
|
|
|
//获取图片文件流
|
|
@@ -204,14 +204,16 @@ public class ImageClassificationFileController extends BladeController {
|
|
|
|
|
|
//获取文件流
|
|
|
byte[] bytes = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(urls.get(i)));
|
|
|
+ byte[] a = new byte[(int) targetSize];
|
|
|
//压缩文件大小
|
|
|
while (bytes.length > targetSize) {
|
|
|
float reduceMultiple = 0.5f;
|
|
|
bytes = FileUtils.resizeImage(bytes, reduceMultiple);
|
|
|
+ a = bytes;
|
|
|
}
|
|
|
|
|
|
//创建图片
|
|
|
- drawing.createPicture(anchor, workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG));
|
|
|
+ drawing.createPicture(anchor, workbook.addPicture(a, Workbook.PICTURE_TYPE_JPEG));
|
|
|
//图片定位
|
|
|
FileUtils.imageOrientation(sheet, anchor, i == 1 ? new DataVO(1, 28) : new DataVO(0, 0));
|
|
|
|
|
@@ -689,18 +691,18 @@ public class ImageClassificationFileController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param urlStr
|
|
|
- * @return 返回Url资源大小
|
|
|
+ * @return 返回Url资源大小
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public long getResourceLength(String urlStr) throws IOException {
|
|
|
- URL url=new URL(urlStr);
|
|
|
- URLConnection urlConnection=url.openConnection();
|
|
|
+ URL url = new URL(urlStr);
|
|
|
+ URLConnection urlConnection = url.openConnection();
|
|
|
urlConnection.connect();
|
|
|
//返回响应报文头字段Content-Length的值
|
|
|
return urlConnection.getContentLength();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 根据字节返回文件大小
|
|
|
*/
|