Merge pull request #3241 from silentnoodlemaster/v3.0

Add option to use lossless webp format
This commit is contained in:
mikeprimm 2021-01-09 18:10:31 -06:00 committed by GitHub
commit bc1fa86823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 15 additions and 14 deletions

View file

@ -73,7 +73,8 @@ public abstract class MapType {
FORMAT_WEBP("webp", 85, ImageEncoding.WEBP),
FORMAT_WEBP90("webp-q90", 90, ImageEncoding.WEBP),
FORMAT_WEBP95("webp-q95", 95, ImageEncoding.WEBP),
FORMAT_WEBP100("webp-q100", 100, ImageEncoding.WEBP);
FORMAT_WEBP100("webp-q100", 100, ImageEncoding.WEBP),
FORMAT_WEBPL("webp-l", 85, ImageEncoding.WEBP);
String id;
float qual;
ImageEncoding enc;

View file

@ -59,7 +59,7 @@ public class ImageIOManager {
fos.close();
// Run encoder to new new temp file
File tmpfile2 = File.createTempFile("pngToWebp", "webp");
String args[] = { core.getCWEBPPath(), "-q", Integer.toString((int)fmt.getQuality()), tmpfile.getAbsolutePath(), "-o", tmpfile2.getAbsolutePath() };
String args[] = { core.getCWEBPPath(), fmt.getID().endsWith("-l")?"-lossless":"", "-q", Integer.toString((int)fmt.getQuality()), tmpfile.getAbsolutePath(), "-o", tmpfile2.getAbsolutePath() };
Process pr = Runtime.getRuntime().exec(args);
try {
pr.waitFor();