Sergey Astanin avatar Sergey Astanin committed 8bd08b3

pdf-trim-to-djvu: shades of gray DjVu mode (--gray)

Comments (0)

Files changed (1)

 
 DPI=300
 MARGIN=10
-MODE=mono # mono or color
+MODE=mono # mono or gray or color
 
 ### End of settings
 
   me=`basename "$prog"`
   if [ $modedefault == "mono" ] ; then
     monodefault="[default]"
+    graydefault=""
+    colordefault=""
+  elif [ $modedefault == "gray" ] ; then
+    monodefault=""
+    graydefault="[default]"
     colordefault=""
   else
     monodefault=""
+    graydefault=""
     colordefault="[default]"
   fi
   cat << END
  -t <int>   the last page to process
  -d <int>   resolution in DPI [default: $dpidefault]
  --mono     bitonal compression (black and white only) $monodefault
- --color    DjVuPhoto compression (color and grayscale images) $colordefault
+ --gray     DjVuPhoto compression (shades of gray images) $graydefault
+ --color    DjVuPhoto compression (color images) $colordefault
  -h|--help  print this message
 
 END
 }
 
-opts=`getopt -l "help,mono,color,colour" "hf:t:d:" "$@"` && eval set -- "$opts"
+opts=`getopt -l "help,mono,gray,grey,color,colour" "hf:t:d:" "$@"` && eval set -- "$opts"
 while true ; do
   case "$1" in
     -h|--help) usage ; exit 0 ;;
     -d) DPI=$2 ; shift 2 ;;
     --mono) MODE=mono ; shift ;;
     --color|--colour) MODE=color ; shift ;;
+    --gray|--grey) MODE=gray ; shift ;;
     --) shift ; break ;;
   esac
 done
   monoopt="-mono"
   pmext="pbm"
   compress="cjb2"
+elif [ $MODE == "gray" ] ; then  # use grayscale compression
+  monoopt=""
+  pmext="ppm"
+  compress="c44 -crcbnone"
 else # use DjVuPhoto compression (suitabable for color and grayscale images)
   monoopt=""
   pmext="ppm"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.