2023-02-24 23:10:45 +01:00
|
|
|
# ref https://tex.stackexchange.com/a/502542
|
|
|
|
|
{
|
|
|
|
|
writers,
|
|
|
|
|
imagemagick,
|
2025-10-02 18:34:10 +02:00
|
|
|
ghostscript,
|
2025-12-27 22:22:54 +01:00
|
|
|
lib,
|
2023-02-24 23:10:45 +01:00
|
|
|
}:
|
|
|
|
|
writers.writeDashBin "scanned" ''
|
2025-12-27 22:22:54 +01:00
|
|
|
export PATH=${
|
|
|
|
|
lib.makeBinPath [
|
|
|
|
|
imagemagick
|
|
|
|
|
ghostscript
|
|
|
|
|
]
|
|
|
|
|
}:$PATH
|
2025-10-02 18:34:10 +02:00
|
|
|
|
2023-02-24 23:10:45 +01:00
|
|
|
[ $# -eq 1 -a -f "$1" -a -r "$1" ] || exit 1
|
|
|
|
|
|
|
|
|
|
${imagemagick}/bin/convert \
|
|
|
|
|
-density 150 \
|
|
|
|
|
"$1" \
|
|
|
|
|
-rotate 0.5 \
|
|
|
|
|
-attenuate 0.25 \
|
|
|
|
|
+noise Multiplicative \
|
|
|
|
|
-colorspace Gray \
|
|
|
|
|
"scanned-$1"
|
|
|
|
|
''
|