From 977b2dfdd23ad448a56a83c6f77275e5635de449 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 24 Oct 2023 17:04:37 +0800 Subject: [PATCH] fix code --- .../dromara/hutool/swing/img/BackgroundRemoval.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/BackgroundRemoval.java b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/BackgroundRemoval.java index 33968343a..8c73a371f 100644 --- a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/BackgroundRemoval.java +++ b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/BackgroundRemoval.java @@ -12,6 +12,7 @@ package org.dromara.hutool.swing.img; +import org.dromara.hutool.core.io.IORuntimeException; import org.dromara.hutool.core.io.file.FileTypeUtil; import org.dromara.hutool.core.array.ArrayUtil; import org.dromara.hutool.core.text.StrUtil; @@ -107,8 +108,7 @@ public class BackgroundRemoval { // 图片输出的格式为 png return ImageIO.write(backgroundRemoval(bufferedImage, override, tolerance), "png", output); } catch (final IOException e) { - e.printStackTrace(); - return false; + throw new IORuntimeException(e); } } @@ -176,8 +176,7 @@ public class BackgroundRemoval { try { return backgroundRemoval(ImageIO.read(new ByteArrayInputStream(outputStream.toByteArray())), override, tolerance); } catch (final IOException e) { - e.printStackTrace(); - return null; + throw new IORuntimeException(e); } } @@ -286,9 +285,8 @@ public class BackgroundRemoval { try { return getMainColor(ImageIO.read(input)); } catch (final IOException e) { - e.printStackTrace(); + throw new IORuntimeException(e); } - return ""; } /**