[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/scanner 6537d71 47/56: add image size customization and
From: |
Stefan Monnier |
Subject: |
[elpa] externals/scanner 6537d71 47/56: add image size customization and update tests |
Date: |
Fri, 10 Apr 2020 13:56:06 -0400 (EDT) |
branch: externals/scanner
commit 6537d71c85a26c9b0f31b8ca7e6a80b90b868ca4
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>
add image size customization and update tests
---
Makefile | 4 ++--
scanner-test.el | 21 ++++++++-------------
scanner.el | 11 +++++++++--
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/Makefile b/Makefile
index 067ba3b..63dcf21 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@
EMACS = emacs
EL = scanner.el
TEST = scanner-test.el
-RUN_ENTRY = scanner.el
-TEST_ENTRY = scanner-test.el
+RUN_ENTRY = scanner.elc
+TEST_ENTRY = scanner-test.elc
ELPA_EXT = dash
LDFLAGS = -L ./dep/dash
diff --git a/scanner-test.el b/scanner-test.el
index 6c16de4..7b4ab9b 100644
--- a/scanner-test.el
+++ b/scanner-test.el
@@ -46,8 +46,6 @@
;;; Code:
-
-(load-file "scanner.el")
(require 'scanner)
(require 'dash)
(require 'ert)
@@ -78,6 +76,7 @@
(let ((scanner--available-switches nil)
(scanner-image-format '(:image "fmt-img" :doc "fmt-doc"))
(scanner-device-name "devname")
+ (scanner-image-size '(200 250))
(-compare-fn #'string=))
;; known values are included with their switches
(should (-is-infix-p '("-d" "devname") (scanner--scanimage-args "file"
@@ -110,6 +109,7 @@
(scanner-scan-mode '(:image "Color" :doc "Gray"))
(scanner-doc-papersize :a4)
(scanner-paper-sizes '(:a4 (210 297)))
+ (scanner-image-size '(200 250))
(-compare-fn #'string=))
(should (-is-infix-p '("-o" "file") (scanner--scanimage-args "file"
:image)))
(should (-contains-p (scanner--scanimage-args "file" :image)
@@ -120,15 +120,9 @@
(should (-contains-p (scanner--scanimage-args "file" :image)
"--resolution=600"))
(should (-is-infix-p '("-x" "210") (scanner--scanimage-args "file" :doc)))
- (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file" :doc))))
- ;; doc args list with device specific args
- (let ((scanner--available-switches '("--resolution" "-x" "-y" "--mode"))
- (scanner-image-format '(:image "fmt-img" :doc "fmt-doc"))
- (scanner-resolution '(:doc 300 :image 600))
- (scanner-scan-mode '(:image "Color" :doc "Gray"))
- (scanner-doc-papersize :a4)
- (scanner-paper-sizes '(:a4 (210 297)))
- (-compare-fn #'string=))
+ (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file" :doc)))
+ (should (-is-infix-p '("-x" "200") (scanner--scanimage-args "file"
:image)))
+ (should (-is-infix-p '("-y" "250") (scanner--scanimage-args "file"
:image)))
(should (-is-infix-p '("-o" "file") (scanner--scanimage-args "file" :doc)))
(should (-contains-p (scanner--scanimage-args "file" :doc)
"--format=fmt-doc"))
@@ -137,8 +131,9 @@
(should (-contains-p (scanner--scanimage-args "file" :doc) "--mode=Gray"))
(should (-contains-p (scanner--scanimage-args "file" :doc)
"--resolution=300"))
- (should (-is-infix-p '("-x" "210") (scanner--scanimage-args "file" :doc)))
- (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file"
:doc)))))
+ (let ((scanner-image-size nil))
+ (should-not (-contains-p (scanner--scanimage-args "file" :image) "-x"))
+ (should-not (-contains-p (scanner--scanimage-args "file" :image)
"-y")))))
(ert-deftest scanner-test-tesseract-args ()
diff --git a/scanner.el b/scanner.el
index 3b0c788..d4c05fc 100644
--- a/scanner.el
+++ b/scanner.el
@@ -107,6 +107,11 @@ The value must be one of the keys in the paper sizes list."
:type '(restricted-sexp :match-alternatives
((lambda (k) (plist-member scanner-paper-sizes k)))))
+(defcustom scanner-image-size
+ '(200 250)
+ "Image size as list of (width height) in mm or nil."
+ :type '(list number number))
+
(defcustom scanner-reverse-pages
nil
"If non-nil, reverse pages in document mode."
@@ -319,8 +324,10 @@ argument for the intermediate representation before
conversion to
the document format. If any of the required options from
‘scanner--device-specific-switches’ are unavailable, they are
simply dropped."
- (let ((size (when (eq :doc type)
- (plist-get scanner-paper-sizes scanner-doc-papersize))))
+ (let ((size (cond ((eq :doc type)
+ (plist-get scanner-paper-sizes scanner-doc-papersize))
+ ((eq :image type) scanner-image-size)
+ (t nil))))
(-flatten (list (and scanner-device-name
(list "-d" scanner-device-name))
(-when-let (fmt (or img-fmt
- [elpa] externals/scanner eab3aea 40/56: cleanup scanner--ensure-init, (continued)
- [elpa] externals/scanner eab3aea 40/56: cleanup scanner--ensure-init, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 1229f38 46/56: add ‘check’ to phony targets, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 72ecf43 56/56: minor clean-ups, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner c439a01 07/56: add scanner--ensure-init, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 9779064 13/56: remove an old FIXME, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 0b0fecf 19/56: make a basic Readme from the commentary, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 00ab593 23/56: rephrase commentary in active voice, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner fdfdb62 33/56: add tesseract outputs selection command, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner d011e65 36/56: implement multi-image scan, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner e17e2fa 41/56: add section headings, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 6537d71 47/56: add image size customization and update tests,
Stefan Monnier <=
- [elpa] externals/scanner bfaae5a 20/56: ignore PDF and text files, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner b058e2f 26/56: autoload the menu, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner d634903 44/56: improve docstring to scanner--determine-image-format, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner a8cdff3 48/56: clean up device switches and docstrings, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner d6af0ae 43/56: clean up tests a bit, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner eee1a77 54/56: remove useless type checks, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner c815ae0 42/56: make Makefile a bit more general, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner 312b0f4 45/56: clean up scanner--scanimage-args, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner b36caab 51/56: add menu entries and command for multiple scans, Stefan Monnier, 2020/04/10
- [elpa] externals/scanner af4923b 35/56: require menu-bar, Stefan Monnier, 2020/04/10