1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

42728: update options in libtiff tools completion and add handling for tiff2pdf

This commit is contained in:
Oliver Kiddle 2018-04-29 23:22:44 +02:00
parent f7519811e1
commit 563a8d2853
2 changed files with 135 additions and 69 deletions

View file

@ -1,3 +1,8 @@
2018-04-29 Oliver Kiddle <okiddle@yahoo.co.uk>
* 42728: Completion/Unix/Command/_tiff: update options and
add handling for tiff2pdf
2018-04-29 Barton E. Schaefer <schaefer@zsh.org> 2018-04-29 Barton E. Schaefer <schaefer@zsh.org>
* Ricardo Giorni: 47201: fix 42355 for multiple backslashes * Ricardo Giorni: 47201: fix 42355 for multiple backslashes

View file

@ -14,7 +14,7 @@ if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then
set -- "$expl[@]" set -- "$expl[@]"
fi fi
_wanted files expl 'picture file' _path_files "$@" -g "$pat" - || _wanted files expl 'picture file' _path_files "$@" -g "$pat" - ||
_files "$@" "$expl[@]" -g '*.(#i)tiff(-.)' _files "$@" "$expl[@]" -g '*.(#i)tif(|f)(-.)'
return return
fi fi
@ -26,87 +26,143 @@ typeset -A opt_args
case "$service" in case "$service" in
tiff2bw) tiff2bw)
_arguments -C \ _arguments -C \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-R[specify percentage of red channel]:percentage of red channel' \ '-R+[specify percentage of red channel]:percentage' \
'-G[specify percentage of green channel]:percentage of green channel' \ '-G+[specify percentage of green channel]:percentage' \
'-B[specify percentage of blue channel]:percentage of blue channel' \ '-B+[specify percentage of blue channel]:percentage' \
':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiff2pdf)
_arguments -s \
'-o+[specify output file]:output file:_files -g "*.(#i)pdf(-.)"' \
'(-z -d)-j[compress with JPEG]' \
'(-j -d)-z[compress with Zip/Deflate]' \
'-q+[specify compression quality]:quality' \
'-n[no compressed data passthrough]' \
"(-z -j)-d[don't compress]" \
'-i[invert colors]' \
'-u+[set distance unit]:unit:((i\:inches m\:centimeters))' \
'-x+[set x resolution]:resolution (dots per unit)' \
'-y+[set y resolution]:resolution (dots per unit)' \
'-w+[specify width in units]:width' \
'-l+[specify length in units]:length' \
'-r+[specify scope for resolution settings]:scope:((d\:images\ without\ resolution o\:all\ images))' \
'-p+[specify paper size]:paper size:(letter legal A4)' \
'-F[make the tiff fill the PDF page]' \
'-f[set PDF "Fit Window" user preference]' \
'-e+[specify date]:date (YYYYMMDDHHMMSS)' \
'-c+[set document creator, overrides image software default]:creator' \
'-a+[set document author, overrides image artist default]:author' \
'-t+[set document title, overrides image document name default]:title' \
'-s+[set document subject, overrides image image description default]:subject' \
'-k+[set document keywords]:keywords' \
'-b[set PDF "Interpolate" user preference]' \
'(- :)-h[display usage information]' \
':input file:_files -g "*.(#i)tif(|f)(-.)"'
;;
tiff2ps) tiff2ps)
_arguments \ _arguments -s \
'-1[generate PostScript Level I output]' \ '!(-2 -3 -8 -m)-1' \
'-2[generate PostScript Level II output]' \ '(-3)-2[generate PostScript Level 2 output]' \
'(-2)-3[generate PostScript Level 3 output]' \
'-8[disable use of ASCII85 encoding with PostScript Level 2/3]' \
'-a[generate output for all IFDs]' \ '-a[generate output for all IFDs]' \
'-d[set initial TIFF directory]:initial TIFF directory' \ '-b+[set the bottom margin]:margin (inches)' \
'(-p)-e[generate Encapsulated PostScript]' \ '-c[center image]' \
'-o[set initial TIFF directory (file offset)]:file offset' \ '-C+[set postscript document creator name]:creator' \
'-d+[set initial TIFF directory]:initial TIFF directory' \
'(-e)-D[print two pages per sheet (duplex)]' \
'(-p -D -T)-e[generate Encapsulated PostScript]' \
'-h+[set printed page height]:height (inches)' \
'-w+[set printed page width]:width (inches)' \
'(-W)-H+[split image if height is more than specified value]:limit (inches)' \
'(-H)-W+[split image if width is more than specified value]:limit (inches)' \
'-L+[specify overlap for split images]:overlap (inches)' \
'-i+[enable/disable (Nz/0) pixel interpolation]:state [enabled]:((0\:disable 1\:enable))' \
'-l+[set the left margin]:margin (inches)' \
'-m[use "imagemask" operator instead of "image"]' \
'-o+[set initial TIFF directory (file offset)]:file offset (bytes)' \
'(-e)-p[generate non-Encapsulated PostScript]' \ '(-e)-p[generate non-Encapsulated PostScript]' \
'-h[set page height]:page height' \ '-O+[specify output file]:output file:_files -g "*.(#i)(|e)ps(-.)"' \
'-w[set page width]:page width' \ '-P+[set PageOrientation DSC comment to Landscape or Portrait]:orientation:(L P)' \
'-8[disable use of ASCII85 encoding]' \ '-r+[rotate image]:rotation:(90 180 270 auto)' \
'-D[print two pages per sheet]' \
'-O[specify output file]:output file:_files -g "*.(#i)ps(-.)"' \
'-s[generate output for a single image]' \ '-s[generate output for a single image]' \
'-T[print pages for top edge binding]' \ '-t+[set postscript document title]:title' \
'(-e)-T[print pages for top edge binding]' \
'(-y)-x[override resolution units as centimeters]' \
'(-x)-y[override resolution units as inches]' \
'-z[enable printing in the deadzone]' \
'*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffcmp) tiffcmp)
_arguments \ _arguments -s \
'-l[list all differing bytes]' \ '-l[list all differing bytes]' \
'-z+[list specified number of bytes that differs between the files]:bytes' \
'-t[ignore differences in directories]' \ '-t[ignore differences in directories]' \
':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \ ':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \
':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffcp) tiffcp)
_arguments -C \ _arguments -C -s \
'-B[write output in bin-endian byte order]' \ '-a[append to output instead of overwriting]' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-o[set initial TIFF directory (file offset)]:file offset' \ '-o+[set initial TIFF directory (file offset)]:file offset' \
'-p[set sample packing]:sample packing:(contig separate)' \ '-p+[set sample packing]:sample packing:(contig separate)' \
'(-t)-s[write output in strips]' \ '(-t)-s[write output in strips]' \
'(-s)-t[write output in tiles]' \ '(-s)-t[write output in tiles]' \
'-x[force the merged tiff pages in sequence]' \
'-8[write BigTIFF instead of default ClassicTIFF]' \
'(-L)-B[write output in big-endian byte order instead of native ordering]' \
'(-B)-L[write output in little-endian byte order instead of native ordering]' \
'-M[disable use of memory-mapped files]' \
'-C[disable strip chopping]' \
'-i[ignore read errors]' \ '-i[ignore read errors]' \
'-r[specify rows per strip]:rows per strip' \ '-b+[specify bias (dark) monochrome image to be subtracted from all others]:file:_files' \
'-w[specify output tile width]:output tile width' \ '-,=-[specify substitute character for image indices]:character [,]' \
'-l[specify output tile length]:output tile length' \ '-r+[specify rows per strip]:rows per strip' \
'-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ '-w+[specify output tile width]:output tile width' \
'*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 '-l+[specify output tile length]:output tile length' \
'-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \
'*:TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffdither) tiffdither)
_arguments -C \ _arguments -C \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-t[set threshold for dithering]:dither threshold value' \ '-t+[set threshold for dithering]:dither threshold value [128]' \
':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffdump) tiffdump)
_arguments \ _arguments \
'-o[set initial TIFF directory (file offset)]:file offset:' \ '-o+[set initial TIFF directory (file offset)]:file offset' \
'-h[print numbers in hexadecimal]' \ '-h[print numbers in hexadecimal]' \
'-m+[change number of indirect items printed]:items [24]' \
'*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffinfo) tiffinfo)
_arguments \ _arguments -s \
'-c[display colormap and color/gray response curves]' \ '-c[display colormap and color/gray response curves]' \
'-D[read and decompress data]' \ '-D[read and decompress data]' \
'-d[print decompressed data]' \ '-d[print decompressed data]' \
'-j[display JPEG-related tags]' \ '-j[display JPEG-related tags]' \
'-o[set initial TIFF directory (file offset)]:file offset' \ '-o+[set initial TIFF directory (file offset)]:file offset' \
'-r[read/display raw image data instead of decoded data]' \
'-s[display offsets and byte counts for all data strips]' \ '-s[display offsets and byte counts for all data strips]' \
'-i[ignore read errors]' \ '-i[ignore read errors]' \
'-f[force fill order]:fill order:(lsb2msb msb2lsb)' \ '-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \
'-w[display raw data in words]' \ '-w[display raw data in words]' \
'-z[enable strip chopping]' \
'*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
tiffmedian) tiffmedian)
_arguments -C \ _arguments -C \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-C[specify number of colormap entries]:number of colormap entries' \ '-C+[specify number of colormap entries]:number of colormap entries' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-f[use Floyd-Steinberg dithering]' \ '-f[use Floyd-Steinberg dithering]' \
':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
@ -117,52 +173,57 @@ tiffsplit)
':output file prefix' && ret=0 ':output file prefix' && ret=0
;; ;;
fax2tiff) fax2tiff)
_arguments \ _arguments -s \
'!(-1 -2 -3 -4)-'{1,3} \
'(-1 -4)-2[input is Group 3, 2d encoded]' \ '(-1 -4)-2[input is Group 3, 2d encoded]' \
'(-2 -4)-1[input is Group 3, 1d encoded]' \ '(-1 -2 -A)-4[input is Group 4 encoded]' \
'(-1 -2)-4[input is Group 4 encoded]' \ '-U[input is uncompressed]' \
'(-W)-B[0 in input is black]' \ '(-4)-A[input is EOL-aligned]' \
'(-B)-W[0 in input is white]' \ '-B[0 in input means black]' \
'(-M)-L[input is lsb-to-msb]' \ '-M[input is msb-to-lsb]' \
'(-L)-M[input is msb-to-lsb]' \ '-R+[specify resolution]:resolution (lines per inch) [196]' \
'-R[specify resolution]:resolution (lines per inch)' \ '-X+[specify input data width]:width [1728]' \
'-o[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \ '-o+[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \
'(-f)-c[generate `classic'"'"' TIFF format]' \ '(-5 -p)-8[generate G4-encoded output]' \
'(-c)-f[generate TIFF Class F format]' \ '-u[generate uncompressed output]' \
'(-8)-5[generate 1d encoded output]' \
"(-8)-p[don't align EOL codes]" \
'-c[generate `classic'"'"' TIFF format]' \
'-m[output in msb-to-lsb order]' \ '-m[output in msb-to-lsb order]' \
"-p[don't align EOL codes]" \ '-r+[specify rows per strip]:rows per strip' \
'-s[duplicate all rows]' \ '-s[stretch image by duplicating all rows]' \
'-v[verbose mode]' \ '-v[verbose mode]' \
'-z[generate LZW compressed output]' \
':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0 ':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0
;; ;;
gif2tiff) gif2tiff)
_arguments -C \ _arguments -C \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
':input GIF file:_files -g "*.(#i)gif(-.)"' \ ':input GIF file:_files -g "*.(#i)gif(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
ppm2tiff) ppm2tiff)
_arguments -C \ _arguments -C \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-R[specify resolution]:resolution:' \ '-R+[specify resolution]:resolution (dots/inch)' \
':input GIF file:_files -g "*.(#i)ppm(-.)"' \ ':input GIF file:_files -g "*.(#i)ppm(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
ras2tiff) ras2tiff)
_arguments -C \ _arguments -C \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \ ':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
pal2rgb) pal2rgb)
_arguments -C \ _arguments -C \
'-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ '-C+[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \
'-p[set sample packing]:sample packing:(contig separate)' \ '-p+[set sample packing]:sample packing:(contig separate)' \
'-c[specify compression scheme]:compression scheme:->compress' \ '-c+[specify compression scheme]:compression scheme:->compress' \
'-r[specify rows per strip]:rows per strip' \ '-r+[specify rows per strip]:rows per strip' \
':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;; ;;
@ -179,7 +240,7 @@ if [[ -n "$state" ]]; then
case "$scheme" in case "$scheme" in
g3) g3)
_values -s : 'FAX Group 3 options' \ _values -s : 'FAX Group 3 option' \
'(2d)1d[use 1D-encoding]' \ '(2d)1d[use 1D-encoding]' \
'(1d)2d[use 2D-encoding]' \ '(1d)2d[use 2D-encoding]' \
'fill[byte-align EOL codes]' && ret=0 'fill[byte-align EOL codes]' && ret=0
@ -188,8 +249,8 @@ if [[ -n "$state" ]]; then
_message -e values "compression quality (0-100), or \`r' (output RGB)" _message -e values "compression quality (0-100), or \`r' (output RGB)"
ret=0 ret=0
;; ;;
lzw|zip) lzw|lzma|zip)
_values 'LZW and deflate options' \ _values 'LZW and deflate option' \
'1[without differencing]' \ '1[without differencing]' \
'2[with differencing]' && ret=0 '2[with differencing]' && ret=0
;; ;;
@ -198,8 +259,8 @@ if [[ -n "$state" ]]; then
_tags values _tags values
while _tags; do while _tags; do
while _next_label values expl 'compression scheme'; do while _next_label values expl 'compression scheme'; do
compadd "$expl[@]" - none g4 packbits && ret=0 compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0
compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 compadd "$expl[@]" -qS: - lzw zip lzma jpeg g3 && ret=0
done done
(( ret )) || return 0 (( ret )) || return 0
done done