This commit is contained in:
Looly 2024-11-14 14:10:27 +08:00
parent 9b3709ad45
commit 7bb487419c
17 changed files with 238 additions and 194 deletions

View File

@ -83,7 +83,7 @@ public class FileTypeUtilTest {
@Test
@Disabled
public void getTypeFromInputStream() throws IOException {
final File file = FileUtil.file("d:/test/pic.jpg");
final File file = FileUtil.file("d:/test/shape.jpg");
final BufferedInputStream inputStream = FileUtil.getInputStream(file);
inputStream.mark(0);
final String type = FileTypeUtil.getType(inputStream);

View File

@ -43,7 +43,7 @@ public class PicTransferTest {
}
private static void save(final ResultSet rs) throws SQLException{
final String destDir = "d:/test/pic";
final String destDir = "d:/test/shape";
final String path = StrUtil.format("{}/{}-{}.jpg", destDir, rs.getString("NAME"), rs.getString("GROUP"));
FileUtil.copy(rs.getBlob("PIC").getBinaryStream(), FileUtil.file(path));
}

View File

@ -66,7 +66,7 @@ public class QrCodeUtilTest {
@Test
@Disabled
public void generateWithLogoTest() {
final String icon = FileUtil.isWindows() ? "d:/test/pic/logo.jpg" : "~/Desktop/hutool/pic/logo.jpg";
final String icon = FileUtil.isWindows() ? "d:/test/shape/logo.jpg" : "~/Desktop/hutool/shape/logo.jpg";
final String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
QrCodeUtil.generate(//
"https://hutool.cn/", //
@ -77,7 +77,7 @@ public class QrCodeUtilTest {
@Test
@Disabled
public void decodeTest() {
final String decode = QrCodeUtil.decode(FileUtil.file("d:/test/pic/qr.png"));
final String decode = QrCodeUtil.decode(FileUtil.file("d:/test/shape/qr.png"));
Console.log(decode);
}
@ -141,7 +141,7 @@ public class QrCodeUtilTest {
@Disabled
public void generateSvgTest() {
final QrConfig qrConfig = QrConfig.of()
.setImg("d:/test/pic/logo.jpg")
.setImg("d:/test/shape/logo.jpg")
.setForeColor(Color.blue)
.setBackColor(Color.pink)
.setRatio(8)

View File

@ -47,7 +47,7 @@ public class DownloadTest {
@Disabled
public void downloadPicTest() {
final String url = "http://wx.qlogo.cn/mmopen/vKhlFcibVUtNBVDjcIowlg0X8aJfHXrTNCEFBukWVH9ta99pfEN88lU39MKspCUCOP3yrFBH3y2NbV7sYtIIlon8XxLwAEqv2/0";
HttpDownloader.downloadFile(url, new File("e:/pic/t3.jpg"));
HttpDownloader.downloadFile(url, new File("e:/shape/t3.jpg"));
Console.log("ok");
}
@ -56,8 +56,8 @@ public class DownloadTest {
@Disabled
public void downloadSizeTest() {
final String url = "https://res.t-io.org/im/upload/img/67/8948/1119501/88097554/74541310922/85/231910/366466 - 副本.jpg";
ClientEngineFactory.getEngine().send(Request.of(url)).body().write("e:/pic/366466.jpg");
//HttpRequest.get(url).setSSLProtocol("TLSv1.2").executeAsync().body().write("e:/pic/366466.jpg");
ClientEngineFactory.getEngine().send(Request.of(url)).body().write("e:/shape/366466.jpg");
//HttpRequest.get(url).setSSLProtocol("TLSv1.2").executeAsync().body().write("e:/shape/366466.jpg");
}
@Test

View File

@ -1,145 +0,0 @@
/*
* Copyright (c) 2013-2024 Hutool Team and hutool.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hutool.poi.excel;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.io.file.FileTypeUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.map.multi.ListValueMap;
import org.dromara.hutool.core.text.StrUtil;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
import java.io.File;
import java.util.List;
/**
* Excel图片工具类
*
* @author looly
* @since 4.0.7
*/
public class ExcelImgUtil {
/**
* 获取图片类型
*
* @param imgFile 图片文件
* @return 图片类型默认PNG
* @since 6.0.0
*/
public static ExcelImgType getImgType(final File imgFile) {
final String type = FileTypeUtil.getType(imgFile);
if (StrUtil.equalsAnyIgnoreCase(type, "jpg", "jpeg")) {
return ExcelImgType.JPEG;
} else if (StrUtil.equalsAnyIgnoreCase(type, "emf")) {
return ExcelImgType.EMF;
} else if (StrUtil.equalsAnyIgnoreCase(type, "wmf")) {
return ExcelImgType.WMF;
} else if (StrUtil.equalsAnyIgnoreCase(type, "pict")) {
return ExcelImgType.PICT;
} else if (StrUtil.equalsAnyIgnoreCase(type, "dib")) {
return ExcelImgType.DIB;
}
// 默认格式
return ExcelImgType.PNG;
}
/**
* 获取工作簿指定sheet中图片列表
*
* @param workbook 工作簿{@link Workbook}
* @param sheetIndex sheet的索引
* @return 图片映射键格式行_列{@link PictureData}
*/
public static ListValueMap<String, PictureData> getPicMap(final Workbook workbook, int sheetIndex) {
Assert.notNull(workbook, "Workbook must be not null !");
if (sheetIndex < 0) {
sheetIndex = 0;
}
if (workbook instanceof HSSFWorkbook) {
return getPicMapXls((HSSFWorkbook) workbook, sheetIndex);
} else if (workbook instanceof XSSFWorkbook) {
return getPicMapXlsx((XSSFWorkbook) workbook, sheetIndex);
} else {
throw new IllegalArgumentException(StrUtil.format("Workbook type [{}] is not supported!", workbook.getClass()));
}
}
// -------------------------------------------------------------------------------------------------------------- Private method start
/**
* 获取XLS工作簿指定sheet中图片列表
*
* @param workbook 工作簿{@link Workbook}
* @param sheetIndex sheet的索引
* @return 图片映射键格式行_列{@link PictureData}
*/
private static ListValueMap<String, PictureData> getPicMapXls(final HSSFWorkbook workbook, final int sheetIndex) {
final ListValueMap<String, PictureData> picMap = new ListValueMap<>();
final List<HSSFPictureData> pictures = workbook.getAllPictures();
if (CollUtil.isNotEmpty(pictures)) {
final HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
HSSFClientAnchor anchor;
int pictureIndex;
for (final HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
if (shape instanceof HSSFPicture) {
pictureIndex = ((HSSFPicture) shape).getPictureIndex() - 1;
anchor = (HSSFClientAnchor) shape.getAnchor();
picMap.putValue(StrUtil.format("{}_{}", anchor.getRow1(), anchor.getCol1()), pictures.get(pictureIndex));
}
}
}
return picMap;
}
/**
* 获取XLSX工作簿指定sheet中图片列表
*
* @param workbook 工作簿{@link Workbook}
* @param sheetIndex sheet的索引
* @return 图片映射键格式行_列{@link PictureData}
*/
private static ListValueMap<String, PictureData> getPicMapXlsx(final XSSFWorkbook workbook, final int sheetIndex) {
final ListValueMap<String, PictureData> sheetIndexPicMap = new ListValueMap<>();
final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
XSSFDrawing drawing;
for (final POIXMLDocumentPart dr : sheet.getRelations()) {
if (dr instanceof XSSFDrawing) {
drawing = (XSSFDrawing) dr;
final List<XSSFShape> shapes = drawing.getShapes();
XSSFPicture pic;
CTMarker ctMarker;
for (final XSSFShape shape : shapes) {
if (shape instanceof XSSFPicture) {
pic = (XSSFPicture) shape;
ctMarker = pic.getPreferredSize().getFrom();
sheetIndexPicMap.putValue(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
}
// 其他类似于图表等忽略see: https://gitee.com/dromara/hutool/issues/I38857
}
}
}
return sheetIndexPicMap;
}
// -------------------------------------------------------------------------------------------------------------- Private method end
}

View File

@ -59,9 +59,9 @@ public class CellSetterFactory {
return new HyperlinkCellSetter((Hyperlink) value);
}else if (value instanceof byte[]) {
// 二进制理解为图片
return new ImgCellSetter((byte[]) value);
return new PicCellSetter((byte[]) value);
}else if (value instanceof File) {
return new ImgCellSetter((File) value);
return new PicCellSetter((File) value);
} else {
return new CharSequenceCellSetter(value.toString());
}

View File

@ -18,8 +18,8 @@ package org.dromara.hutool.poi.excel.cell.setters;
import org.apache.poi.ss.usermodel.*;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.poi.excel.ExcelImgType;
import org.dromara.hutool.poi.excel.ExcelImgUtil;
import org.dromara.hutool.poi.excel.shape.ExcelPicType;
import org.dromara.hutool.poi.excel.shape.ExcelPicUtil;
import org.dromara.hutool.poi.excel.SimpleClientAnchor;
import org.dromara.hutool.poi.excel.writer.ExcelDrawingUtil;
@ -31,10 +31,10 @@ import java.io.File;
* @author Looly
* @since 6.0.0
*/
public class ImgCellSetter implements CellSetter {
public class PicCellSetter implements CellSetter {
private final byte[] pictureData;
private final ExcelImgType imgType;
private final ExcelPicType picType;
// region ----- 构造
@ -43,8 +43,8 @@ public class ImgCellSetter implements CellSetter {
*
* @param pictureData 图片数据
*/
public ImgCellSetter(final byte[] pictureData) {
this(pictureData, ExcelImgType.PNG);
public PicCellSetter(final byte[] pictureData) {
this(pictureData, ExcelPicType.PNG);
}
/**
@ -52,19 +52,19 @@ public class ImgCellSetter implements CellSetter {
*
* @param picturefile 图片数据
*/
public ImgCellSetter(final File picturefile) {
this(FileUtil.readBytes(picturefile), ExcelImgUtil.getImgType(picturefile));
public PicCellSetter(final File picturefile) {
this(FileUtil.readBytes(picturefile), ExcelPicUtil.getPicType(picturefile));
}
/**
* 构造
*
* @param pictureData 图片数据
* @param imgType 图片类型
* @param picType 图片类型
*/
public ImgCellSetter(final byte[] pictureData, final ExcelImgType imgType) {
public PicCellSetter(final byte[] pictureData, final ExcelPicType picType) {
this.pictureData = pictureData;
this.imgType = imgType;
this.picType = picType;
}
// endregion
@ -74,7 +74,7 @@ public class ImgCellSetter implements CellSetter {
final int columnIndex = cell.getColumnIndex();
final int rowIndex = cell.getRowIndex();
ExcelDrawingUtil.drawingImg(sheet, this.pictureData, this.imgType,
ExcelDrawingUtil.drawingPic(sheet, this.pictureData, this.picType,
new SimpleClientAnchor(columnIndex, rowIndex, columnIndex + 1, rowIndex + 1));
}
}

View File

@ -17,10 +17,7 @@
package org.dromara.hutool.poi.excel.reader;
import org.apache.poi.ss.extractor.ExcelExtractor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.dromara.hutool.core.func.SerBiConsumer;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.io.file.FileUtil;
@ -28,6 +25,7 @@ import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.poi.excel.*;
import org.dromara.hutool.poi.excel.cell.CellUtil;
import org.dromara.hutool.poi.excel.reader.sheet.*;
import org.dromara.hutool.poi.excel.shape.ExcelPicUtil;
import org.dromara.hutool.poi.excel.writer.ExcelWriter;
import java.io.File;
@ -364,6 +362,16 @@ public class ExcelReader extends ExcelBase<ExcelReader, ExcelReadConfig> {
return CellUtil.getCellValue(getCell(x, y), this.config.getCellEditor());
}
/**
* 读取绘制的图片列表
*
* @return 图片列表
* @since 6.0.0
*/
public List<Picture> readPics() {
return ExcelPicUtil.getShapePics(this.sheet);
}
/**
* 获取Excel写出器<br>
* 在读取Excel并做一定编辑后获取写出器写出规则如下

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.dromara.hutool.poi.excel;
package org.dromara.hutool.poi.excel.shape;
import org.apache.poi.ss.usermodel.Workbook;
@ -30,7 +30,7 @@ import org.apache.poi.ss.usermodel.Workbook;
* @see Workbook#PICTURE_TYPE_DIB
* @since 6.0.0
*/
public enum ExcelImgType {
public enum ExcelPicType {
/**
* Extended windows meta file
*/
@ -68,7 +68,7 @@ public enum ExcelImgType {
*
* @param value 类型编码
*/
ExcelImgType(final int value) {
ExcelPicType(final int value) {
this.value = value;
}

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 2013-2024 Hutool Team and hutool.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hutool.poi.excel.shape;
import org.apache.poi.ss.usermodel.*;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.io.file.FileTypeUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.stream.StreamUtil;
import org.dromara.hutool.core.text.StrUtil;
import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
/**
* Excel图片工具类
*
* @author looly
* @since 4.0.7
*/
public class ExcelPicUtil {
/**
* 获取图片类型
*
* @param picFile 图片文件
* @return 图片类型默认PNG
* @since 6.0.0
*/
public static ExcelPicType getPicType(final File picFile) {
final String type = FileTypeUtil.getType(picFile);
if (StrUtil.equalsAnyIgnoreCase(type, "jpg", "jpeg")) {
return ExcelPicType.JPEG;
} else if (StrUtil.equalsAnyIgnoreCase(type, "emf")) {
return ExcelPicType.EMF;
} else if (StrUtil.equalsAnyIgnoreCase(type, "wmf")) {
return ExcelPicType.WMF;
} else if (StrUtil.equalsAnyIgnoreCase(type, "pict")) {
return ExcelPicType.PICT;
} else if (StrUtil.equalsAnyIgnoreCase(type, "dib")) {
return ExcelPicType.DIB;
}
// 默认格式
return ExcelPicType.PNG;
}
/**
* 写入图片到文件
*
* @param pic 图片数据
* @param file 文件
*/
public static void writePicTo(final Picture pic, final File file) {
writePicTo(pic.getPictureData(), file);
}
/**
* 写入图片到文件
*
* @param pic 图片数据
* @param file 文件
*/
public static void writePicTo(final PictureData pic, final File file) {
FileUtil.writeBytes(pic.getData(), file);
}
/**
* 获取所有图片列表
*
* @param workbook 工作簿{@link Workbook}
* @return 图片列表
*/
public static List<? extends PictureData> getAllPictures(final Workbook workbook) {
return workbook.getAllPictures();
}
/**
* 获取工作簿指定sheet中绘制的图片列表
*
* @param workbook 工作簿{@link Workbook}
* @param sheetIndex sheet的索引
* @return 图片映射键格式行_列{@link PictureData}
*/
public static List<Picture> getShapePics(final Workbook workbook, int sheetIndex) {
Assert.notNull(workbook, "Workbook must be not null !");
if (sheetIndex < 0) {
sheetIndex = 0;
}
return getShapePics(workbook.getSheetAt(sheetIndex));
}
/**
* 获取工作簿指定sheet中绘制的图片列表<br>
* 结果中{@link Picture#getClientAnchor()}标识位置信息{@link Picture#getPictureData()}标识图片数据
*
* @param sheet 工作表{@link Sheet}
* @return 图片列表
*/
public static List<Picture> getShapePics(final Sheet sheet) {
Assert.notNull(sheet, "Sheet must be not null !");
final Drawing<?> drawing = sheet.getDrawingPatriarch();
if (null == drawing) {
return ListUtil.empty();
}
return StreamUtil.of(drawing)
.filter(shape -> shape instanceof Picture)
.map(shape -> (Picture) shape)
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2024 Hutool Team and hutool.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Excel中绘图相关操作
*/
package org.dromara.hutool.poi.excel.shape;

View File

@ -23,7 +23,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
import org.dromara.hutool.poi.excel.ExcelImgType;
import org.dromara.hutool.poi.excel.shape.ExcelPicType;
import org.dromara.hutool.poi.excel.SimpleClientAnchor;
import org.dromara.hutool.poi.excel.style.ShapeConfig;
@ -49,8 +49,8 @@ public class ExcelDrawingUtil {
* @author vhukze
* @since 6.0.0
*/
public static void drawingImg(final Sheet sheet, final byte[] pictureData,
final ExcelImgType imgType, final SimpleClientAnchor clientAnchor) {
public static void drawingPic(final Sheet sheet, final byte[] pictureData,
final ExcelPicType imgType, final SimpleClientAnchor clientAnchor) {
final Drawing<?> patriarch = sheet.createDrawingPatriarch();
final Workbook workbook = sheet.getWorkbook();
final ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();

View File

@ -29,6 +29,8 @@ import org.dromara.hutool.poi.POIException;
import org.dromara.hutool.poi.excel.*;
import org.dromara.hutool.poi.excel.cell.CellRangeUtil;
import org.dromara.hutool.poi.excel.cell.CellUtil;
import org.dromara.hutool.poi.excel.shape.ExcelPicType;
import org.dromara.hutool.poi.excel.shape.ExcelPicUtil;
import org.dromara.hutool.poi.excel.style.*;
import java.awt.Color;
@ -769,7 +771,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
}
// endregion
// region ----- writeImg
// region ----- writePic
/**
* 写出数据本方法只是将数据写入Workbook中的Sheet并不写出到文件<br>
@ -784,8 +786,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
* @author vhukze
* @since 5.7.18
*/
public ExcelWriter writeImg(final File imgFile, final int col1, final int row1, final int col2, final int row2) {
return writeImg(imgFile, new SimpleClientAnchor(col1, row1, col2, row2));
public ExcelWriter writePic(final File imgFile, final int col1, final int row1, final int col2, final int row2) {
return writePic(imgFile, new SimpleClientAnchor(col1, row1, col2, row2));
}
/**
@ -798,8 +800,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
* @author vhukze
* @since 6.0.0
*/
public ExcelWriter writeImg(final File imgFile, final SimpleClientAnchor clientAnchor) {
return writeImg(imgFile, ExcelImgUtil.getImgType(imgFile), clientAnchor);
public ExcelWriter writePic(final File imgFile, final SimpleClientAnchor clientAnchor) {
return writePic(imgFile, ExcelPicUtil.getPicType(imgFile), clientAnchor);
}
/**
@ -813,8 +815,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
* @author vhukze
* @since 6.0.0
*/
public ExcelWriter writeImg(final File imgFile, final ExcelImgType imgType, final SimpleClientAnchor clientAnchor) {
return writeImg(FileUtil.readBytes(imgFile), imgType, clientAnchor);
public ExcelWriter writePic(final File imgFile, final ExcelPicType imgType, final SimpleClientAnchor clientAnchor) {
return writePic(FileUtil.readBytes(imgFile), imgType, clientAnchor);
}
/**
@ -828,8 +830,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
* @author vhukze
* @since 6.0.0
*/
public ExcelWriter writeImg(final byte[] pictureData, final ExcelImgType imgType, final SimpleClientAnchor clientAnchor) {
ExcelDrawingUtil.drawingImg(this.sheet, pictureData, imgType, clientAnchor);
public ExcelWriter writePic(final byte[] pictureData, final ExcelPicType imgType, final SimpleClientAnchor clientAnchor) {
ExcelDrawingUtil.drawingPic(this.sheet, pictureData, imgType, clientAnchor);
return this;
}

View File

@ -0,0 +1,29 @@
package org.dromara.hutool.poi.excel.shape;
import org.apache.poi.ss.usermodel.Picture;
import org.apache.poi.ss.usermodel.Workbook;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.poi.excel.WorkbookUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.List;
public class ExcelPicUtilTest {
@Test
@Disabled
void readPicTest() {
final Workbook book = WorkbookUtil.createBook("d:/test/poi/a.xlsx");
final List<Picture> picMap = ExcelPicUtil.getShapePics(
WorkbookUtil.createBook("d:/test/poi/a.xlsx"), 0);
Console.log(picMap);
// final List<? extends PictureData> allPictures = book.getAllPictures();
// for (PictureData shape : allPictures) {
// Console.log(shape);
// }
IoUtil.closeQuietly(book);
}
}

View File

@ -835,7 +835,7 @@ public class ExcelWriteTest {
final File file = new File("C:\\Users\\zsz\\Desktop\\1.jpg");
writer.writeImg(file, 0, 0, 5, 10);
writer.writePic(file, 0, 0, 5, 10);
writer.flush(new File("C:\\Users\\zsz\\Desktop\\2.xlsx"), true);

View File

@ -33,7 +33,7 @@ public class ImgTest {
@Test
@Disabled
public void cutTest1() {
Img.from(FileUtil.file("e:/pic/face.jpg")).cut(0, 0, 200).write(FileUtil.file("e:/pic/face_radis.png"));
Img.from(FileUtil.file("e:/shape/face.jpg")).cut(0, 0, 200).write(FileUtil.file("e:/shape/face_radis.png"));
}
@Test
@ -52,7 +52,7 @@ public class ImgTest {
@Test
@Disabled
public void roundTest() {
Img.from(FileUtil.file("e:/pic/face.jpg")).round(0.5).write(FileUtil.file("e:/pic/face_round.png"));
Img.from(FileUtil.file("e:/shape/face.jpg")).round(0.5).write(FileUtil.file("e:/shape/face_round.png"));
}
@Test

View File

@ -37,7 +37,7 @@ public class ImgUtilTest {
@Test
@Disabled
public void scaleTest() {
ImgUtil.scale(FileUtil.file("e:/pic/test.jpg"), FileUtil.file("e:/pic/test_result.jpg"), 0.8f);
ImgUtil.scale(FileUtil.file("e:/shape/test.jpg"), FileUtil.file("e:/shape/test_result.jpg"), 0.8f);
}
@Test
@ -71,8 +71,8 @@ public class ImgUtilTest {
@Test
@Disabled
public void rotateTest() throws IOException {
final Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("e:/pic/366466.jpg")), 180);
ImgUtil.write(image, FileUtil.file("e:/pic/result.png"));
final Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("e:/shape/366466.jpg")), 180);
ImgUtil.write(image, FileUtil.file("e:/shape/result.png"));
}
@Test
@ -148,8 +148,8 @@ public class ImgUtilTest {
@Test
@Disabled
public void copyTest() {
final BufferedImage image = ImgUtil.copyImage(ImgUtil.read("f:/pic/test.png"), BufferedImage.TYPE_INT_RGB);
ImgUtil.write(image, FileUtil.file("f:/pic/test_dest.jpg"));
final BufferedImage image = ImgUtil.copyImage(ImgUtil.read("f:/shape/test.png"), BufferedImage.TYPE_INT_RGB);
ImgUtil.write(image, FileUtil.file("f:/shape/test_dest.jpg"));
}
@Test