Java出现下面错误libpng warning: iCCP: known incorrect sRGB profile要怎么改
时间: 2023-12-17 07:28:58 浏览: 119
解决报错libpng waring:iccp:known incorrect srgb profile
出现libpng warning: iCCP: known incorrect sRGB profile的问题是因为图片的颜色空间不正确,可以通过以下两种方式解决该问题:
1.使用BufferedImage读取图片并重新写入
```java
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class ImageTest {
public static void main(String[] args) throws Exception {
File input = new File("input.png");
BufferedImage image = ImageIO.read(input);
File output = new File("output.png");
ImageIO.write(image, "png", output);
}
}
```
2.使用ImageIO读取图片并重新写入
```java
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class ImageTest {
public static void main(String[] args) throws Exception {
File input = new File("input.png");
BufferedImage image = ImageIO.read(input);
File output = new File("output.png");
ImageIO.write(image, "png", output);
}
}
```
阅读全文