Open Ali-RS opened 3 years ago
What's the type of the output image? I notice that I get that error when I try to write an image of type TYPE_BYTE_GRAY
.
What's the type of the output image? I notice that I get that error when I try to write an image of type
TYPE_BYTE_GRAY
.
And upon further investigation, it appears that lossless variant of the WebP format supports only ARGB. Someone correct me if I'm wrong. So this is a limitation of WebP, not a bug in webp-imageio. Although maybe webp-imageio should check the image type when encoding to WebP, and throw an IllegalArgumentException
for types it doesn't support.
Hi @fleminra
I am using the default settings. Can you please let me know how I can specify it and what output type should I use for the glow map?
This the code snippet I am using to export the image
// Obtain image
try {
BufferedImage image = ImageIO.read(new File(convert.getSourceRoot(), key.getName()));
// Obtain a WebP ImageWriter instance
ImageWriter writer = ImageIO.getImageWritersByMIMEType("image/webp").next();
// Configure encoding parameters
WebPWriteParam writeParam = new WebPWriteParam(writer.getLocale());
writeParam.setCompressionMode(WebPWriteParam.MODE_DEFAULT);
// writeParam.setCompressionMode(WebPWriteParam.MODE_EXPLICIT);
// writeParam.setCompressionType(writeParam.getCompressionTypes()[WebPWriteParam.LOSSY_COMPRESSION]);
// writeParam.setCompressionQuality(0.9f);
// Configure the output on the ImageWriter
writer.setOutput(new FileImageOutputStream(outputFile));
// Encode
writer.write(null, new IIOImage(image, null, null), writeParam);
} catch (Exception e) {
log.error("Error converting texture to WebP. Using original texture instead.", e);
convertedTextures.remove(outputFile.getPath());
continue;
}
Hi
When trying to convert an emissive map (glow map) from jpg to webp using ImageIO and this plugin, I am getting this error:
this is the texture:
When I am converting it to webp with Gimp it converts Ok.