Fix webp v1.2.x

This commit is contained in:
Mike Primm 2021-12-22 22:33:10 -06:00
parent efceaf2d8d
commit 895dcf3244

View File

@ -2,6 +2,7 @@ package org.dynmap.utils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DirectColorModel; import java.awt.image.DirectColorModel;
@ -59,8 +60,17 @@ public class ImageIOManager {
fos.close(); fos.close();
// Run encoder to new new temp file // Run encoder to new new temp file
File tmpfile2 = File.createTempFile("pngToWebp", "webp"); File tmpfile2 = File.createTempFile("pngToWebp", "webp");
String args[] = { core.getCWEBPPath(), fmt.getID().endsWith("-l")?"-lossless":"", "-q", Integer.toString((int)fmt.getQuality()), tmpfile.getAbsolutePath(), "-o", tmpfile2.getAbsolutePath() }; ArrayList<String> args = new ArrayList<String>();
Process pr = Runtime.getRuntime().exec(args); args.add(core.getCWEBPPath());
if (fmt.getID().endsWith("-l")) {
args.add("-lossless");
}
args.add("-q");
args.add(Integer.toString((int)fmt.getQuality()));
args.add(tmpfile.getAbsolutePath());
args.add("-o");
args.add(tmpfile2.getAbsolutePath());
Process pr = Runtime.getRuntime().exec(args.toArray(new String[0]));
try { try {
pr.waitFor(); pr.waitFor();
} catch (InterruptedException ix) { } catch (InterruptedException ix) {