Commit f85b3b28 by Tobias

Added capacity option to CLI

1 parent 9b5e5b4b
......@@ -13,6 +13,7 @@ import org.stegosuite.image.format.ImageFormat;
import org.stegosuite.model.exception.SteganoEmbedException;
import org.stegosuite.model.exception.SteganoExtractException;
import org.stegosuite.model.exception.SteganoImageException;
import org.stegosuite.ui.gui.ImageUtils;
public class Cli implements StegosuiteUI {
......@@ -54,6 +55,13 @@ public class Cli implements StegosuiteUI {
presenter.extractUsing(key);
}
public void capacity(CommandLine cmd) {
String steganogramPath = cmd.getOptionValue("c");
if (!validImageFormat(steganogramPath)) return;
int capacity = presenter.getEmbeddingCapacity();
LOG.info("Capacity: {}",ImageUtils.formatSize(capacity));
}
private boolean validImageFormat(String steganogramPath) {
image = getImageFormat(steganogramPath);
if (image == null) {
......
......@@ -23,7 +23,7 @@ public class CliParser {
options.addOption("x", "extract", true, "extract data from image");
options.addOption("m", "message", true, "message to embed");
options.addOption("k", "key", true, "secret key used for encrytion and hiding");
options.addOption("c", "capacity", true, "shows the maximum amount of data which can be embededded"); // TODO
options.addOption("c", "capacity", true, "shows the maximum amount of data which can be embededded");
options.addOption("h", "help", false, "displays this help message");
Option files = Option.builder("f").hasArgs().longOpt("file").build();
......@@ -58,6 +58,8 @@ public class CliParser {
cli.embed(line);
} else if (line.hasOption("x")) {
cli.extract(line);
} else if (line.hasOption("c")) {
cli.capacity(line);
} else if (line.hasOption("h")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("stegosuite", options);
......
......@@ -3,7 +3,7 @@ package org.stegosuite.ui.gui;
public class ImageUtils {
// taken from http://stackoverflow.com/a/24805871
static String formatSize(long v) {
public static String formatSize(long v) {
if (v < 1024) {
return v + " B";
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!