Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to use JPEG compression #13

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ You can configure the tool via environment variables:
| RENAME_GUI_SCANTOEMAIL="Scan rear pages" | optional | renames GUI button "Scan to email" to "Scan rear pages" |
| RENAME_GUI_SCANTOIMAGE="Scan photo" | optional | renames GUI button "Scan to image" to "Scan photo" |
| RENAME_GUI_SCANTOOCR="Scan High-Res" | optional | renames GUI button "Scan to OCR" to "Scan High-Res" |
| USE_JPEG_COMPRESSION | optional | use JPEG compression when creating PDFs |

### FTPS upload
In addition to the storage in the mounted volume, you can use FTPS (Secure FTP) Upload.
Expand Down Expand Up @@ -237,4 +238,4 @@ This way you can customize the actions running on your scanner.
Hint: These scripts don't necessarily need to do scanning tasks.
You can add any shell script here.

You may mount the scripts in this repository like this: ```-v "$PWD/script/:/opt/brother/scanner/brscan-skey/script/"```
You may mount the scripts in this repository like this: ```-v "$PWD/script/:/opt/brother/scanner/brscan-skey/script/"```
9 changes: 8 additions & 1 deletion script/scanRear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ if [[ $RESOLUTION ]]; then
else
resolution=300
fi

if [ "$USE_JPEG_COMPRESSION" = "true" ]; then
compression_flag="-compress JPEG -quality 80"
else
compression_flag=""
fi

device=$1
cd /scans
date=$(ls -rd */ | grep $(date +"%Y-%m-%d") | head -1)
Expand Down Expand Up @@ -66,7 +73,7 @@ fi

(
echo "converting to PDF for $date..."
gm convert -page A4+0+0 *.pnm /scans/$date.pdf
gm convert -page A4+0+0 $compression_flag *.pnm /scans/$date.pdf
/opt/brother/scanner/brscan-skey/script/trigger_inotify.sh "${SSH_USER}" "${SSH_PASSWORD}" "${SSH_HOST}" "${SSH_PATH}" $date.pdf

echo "cleaning up for $date..."
Expand Down
9 changes: 8 additions & 1 deletion script/scantofile-0.2.4-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ if [[ $RESOLUTION ]]; then
else
resolution=300
fi

if [ "$USE_JPEG_COMPRESSION" = "true" ]; then
compression_flag="-compress JPEG -quality 80"
else
compression_flag=""
fi

device=$1
date=$(date +%Y-%m-%d-%H-%M-%S)

Expand Down Expand Up @@ -49,7 +56,7 @@ fi

(
echo "converting to PDF for $date..."
gm convert -page A4+0+0 $filename_base*.pnm /scans/$date.pdf
gm convert -page A4+0+0 $compression_flag $filename_base*.pnm /scans/$date.pdf
/opt/brother/scanner/brscan-skey/script/trigger_inotify.sh "${SSH_USER}" "${SSH_PASSWORD}" "${SSH_HOST}" "${SSH_PATH}" $date.pdf

echo "cleaning up for $date..."
Expand Down