From a5773d6ab6dd405129e2079cc4c71cc1427c142a Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 4 Jun 2023 18:52:59 +0300 Subject: [PATCH] Support for decoding webp images --- .../meviz/encoder/FormatsRegistry.java | 3 +- .../meviz/encoder/converters/WebpDecoder.java | 42 +++++++++++++++++++ .../{Cwebp.java => WebpEncoder.java} | 5 ++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpDecoder.java rename src/main/java/eu/svjatoslav/meviz/encoder/converters/{Cwebp.java => WebpEncoder.java} (94%) diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java index c0de0fd..4421846 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java @@ -22,7 +22,8 @@ public class FormatsRegistry { // image conversion registerEncoder(new Convert()); - registerEncoder(new Cwebp()); + registerEncoder(new WebpEncoder()); + registerEncoder(new WebpDecoder()); // image to text (OCR) registerEncoder(new Ocr()); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpDecoder.java b/src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpDecoder.java new file mode 100644 index 0000000..8d68562 --- /dev/null +++ b/src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpDecoder.java @@ -0,0 +1,42 @@ +/* + * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. + */ + +package eu.svjatoslav.meviz.encoder.converters; + +import eu.svjatoslav.meviz.encoder.EncodingOptions; + +import java.io.File; +import java.util.List; + +/** + * webp decoder. + */ + +public class WebpDecoder extends AbstractConverter { + + @Override + public String getCommand(final File inputFile, final File targetFile, + final EncodingOptions options, String targetFormat) { + + return "dwebp \"" + inputFile.getAbsolutePath() + "\" -o \"" + + targetFile.getAbsolutePath() + "\""; + } + + @Override + public List getTargetFileExtensions() { + return toList("png"); + } + + @Override + public List getSourceFileExtensions() { + return toList("webp"); + } + + @Override + public boolean isTerminalMandatory() { + return false; + } + +} diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/converters/Cwebp.java b/src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpEncoder.java similarity index 94% rename from src/main/java/eu/svjatoslav/meviz/encoder/converters/Cwebp.java rename to src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpEncoder.java index ca329e0..f3ac18e 100644 --- a/src/main/java/eu/svjatoslav/meviz/encoder/converters/Cwebp.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/converters/WebpEncoder.java @@ -10,7 +10,10 @@ import eu.svjatoslav.meviz.encoder.EncodingOptions; import java.io.File; import java.util.List; -public class Cwebp extends AbstractConverter { +/** + * webp encoder. + */ +public class WebpEncoder extends AbstractConverter { @Override public String getCommand(final File inputFile, final File targetFile, -- 2.20.1