99.9 for blanks

This commit is contained in:
Anthony Stirling 2023-05-12 20:42:45 +01:00
parent ed35a878a5
commit c27f99ab58
3 changed files with 3 additions and 3 deletions

View file

@ -27,7 +27,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Detect if an image is considered blank or not.') parser = argparse.ArgumentParser(description='Detect if an image is considered blank or not.')
parser.add_argument('image_path', help='The path to the image file.') parser.add_argument('image_path', help='The path to the image file.')
parser.add_argument('-t', '--threshold', type=int, default=10, help='Threshold for determining white pixels. The default value is 10.') parser.add_argument('-t', '--threshold', type=int, default=10, help='Threshold for determining white pixels. The default value is 10.')
parser.add_argument('-w', '--white_percent', type=int, default=99, help='The percentage of white pixels for an image to be considered blank. The default value is 99.') parser.add_argument('-w', '--white_percent', type=float, default=99, help='The percentage of white pixels for an image to be considered blank. The default value is 99.')
args = parser.parse_args() args = parser.parse_args()
blank = is_blank_image(args.image_path, args.threshold, args.white_percent) blank = is_blank_image(args.image_path, args.threshold, args.white_percent)

View file

@ -36,7 +36,7 @@ public class BlankPageController {
@PostMapping(consumes = "multipart/form-data", value = "/remove-blanks") @PostMapping(consumes = "multipart/form-data", value = "/remove-blanks")
public ResponseEntity<byte[]> removeBlankPages(@RequestPart(required = true, value = "fileInput") MultipartFile inputFile, public ResponseEntity<byte[]> removeBlankPages(@RequestPart(required = true, value = "fileInput") MultipartFile inputFile,
@RequestParam(defaultValue = "10", name = "threshold") int threshold, @RequestParam(defaultValue = "10", name = "threshold") int threshold,
@RequestParam(defaultValue = "99", name = "whitePercent") int whitePercent) throws IOException, InterruptedException { @RequestParam(defaultValue = "99.9", name = "whitePercent") float whitePercent) throws IOException, InterruptedException {
PDDocument document = null; PDDocument document = null;
try { try {
document = PDDocument.load(inputFile.getInputStream()); document = PDDocument.load(inputFile.getInputStream());

View file

@ -23,7 +23,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="whitePercent" th:text="#{removeBlanks.whitePercent}"></label> <label for="whitePercent" th:text="#{removeBlanks.whitePercent}"></label>
<input type="number" class="form-control" id="whitePercent" name="whitePercent" value="99"> <input type="number" class="form-control" id="whitePercent" name="whitePercent" value="99.9" step="0.1">
<small id="whitePercentHelp" class="form-text text-muted" th:text="#{removeBlanks.whitePercentDesc}"></small> <small id="whitePercentHelp" class="form-text text-muted" th:text="#{removeBlanks.whitePercentDesc}"></small>
</div> </div>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{removeBlanks.submit}"></button> <button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{removeBlanks.submit}"></button>