1#compdef -P (tiff*|*2tiff|pal2rgb)
2
3local pat expl ret=1
4
5if [[ "$service" = *2tiff ]]; then
6  pat="*.(#i)${service}(-.)"
7else
8  pat='*.(#i)tiff(-.)'
9fi
10
11if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then
12  if (( ! $# )); then
13    _description files expl 'picture file'
14    set -- "$expl[@]"
15  fi
16  _wanted files expl 'picture file' _path_files "$@" -g "$pat" - ||
17      _files "$@" "$expl[@]" -g '*.(#i)tiff(-.)'
18  return
19fi
20
21local _in_tiff=yes
22
23local curcontext="$curcontext" state line ret=1
24typeset -A opt_args
25
26case "$service" in
27tiff2bw)
28  _arguments -C \
29    '-c[specify compression scheme]:compression scheme:->compress' \
30    '-r[specify rows per strip]:rows per strip' \
31    '-R[specify percentage of red channel]:percentage of red channel' \
32    '-G[specify percentage of green channel]:percentage of green channel' \
33    '-B[specify percentage of blue channel]:percentage of blue channel' \
34    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
35    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
36  ;;
37tiff2ps)
38  _arguments \
39    '-1[generate PostScript Level I output]' \
40    '-2[generate PostScript Level II output]' \
41    '-a[generate output for all IFDs]' \
42    '-d[set initial TIFF directory]:initial TIFF directory' \
43    '(-p)-e[generate Encapsulated PostScript]' \
44    '-o[set initial TIFF directory (file offset)]:file offset' \
45    '(-e)-p[generate non-Encapsulated PostScript]' \
46    '-h[set page height]:page height' \
47    '-w[set page width]:page width' \
48    '-8[disable use of ASCII85 encoding]' \
49    '-D[print two pages per sheet]' \
50    '-O[specify output file]:output file:_files -g "*.(#i)ps(-.)"' \
51    '-s[generate output for a single image]' \
52    '-T[print pages for top edge binding]' \
53    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
54  ;;
55tiffcmp)
56  _arguments \
57    '-l[list all differing bytes]' \
58    '-t[ignore differences in directories]' \
59    ':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \
60    ':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
61  ;;
62tiffcp)
63  _arguments -C \
64    '-B[write output in bin-endian byte order]' \
65    '-c[specify compression scheme]:compression scheme:->compress' \
66    '-o[set initial TIFF directory (file offset)]:file offset' \
67    '-p[set sample packing]:sample packing:(contig separate)' \
68    '(-t)-s[write output in strips]' \
69    '(-s)-t[write output in tiles]' \
70    '-i[ignore read errors]' \
71    '-r[specify rows per strip]:rows per strip' \
72    '-w[specify output tile width]:output tile width' \
73    '-l[specify output tile length]:output tile length' \
74    '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \
75    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
76  ;;
77tiffdither)
78  _arguments -C \
79    '-c[specify compression scheme]:compression scheme:->compress' \
80    '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \
81    '-r[specify rows per strip]:rows per strip' \
82    '-t[set threshold for dithering]:dither threshold value' \
83    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
84    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
85  ;;
86tiffdump)
87  _arguments \
88    '-o[set initial TIFF directory (file offset)]:file offset:' \
89    '-h[print numbers in hexadecimal]' \
90    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
91  ;;
92tiffinfo)
93  _arguments \
94    '-c[display colormap and color/gray response curves]' \
95    '-D[read and decompress data]' \
96    '-d[print decompressed data]' \
97    '-j[display JPEG-related tags]' \
98    '-o[set initial TIFF directory (file offset)]:file offset' \
99    '-s[display offsets and byte counts for all data strips]' \
100    '-i[ignore read errors]' \
101    '-f[force fill order]:fill order:(lsb2msb msb2lsb)' \
102    '-w[display raw data in words]' \
103    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
104  ;;
105tiffmedian)
106  _arguments -C \
107    '-r[specify rows per strip]:rows per strip' \
108    '-C[specify number of colormap entries]:number of colormap entries' \
109    '-c[specify compression scheme]:compression scheme:->compress' \
110    '-f[use Floyd-Steinberg dithering]' \
111    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
112    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
113  ;;
114tiffsplit)
115  _arguments \
116    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
117    ':output file prefix' && ret=0
118  ;;
119fax2tiff)
120  _arguments \
121    '(-1 -4)-2[input is Group 3, 2d encoded]' \
122    '(-2 -4)-1[input is Group 3, 1d encoded]' \
123    '(-1 -2)-4[input is Group 4 encoded]' \
124    '(-W)-B[0 in input is black]' \
125    '(-B)-W[0 in input is white]' \
126    '(-M)-L[input is lsb-to-msb]' \
127    '(-L)-M[input is msb-to-lsb]' \
128    '-R[specify resolution]:resolution (lines per inch)' \
129    '-o[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \
130    '(-f)-c[generate `classic'"'"' TIFF format]' \
131    '(-c)-f[generate TIFF Class F format]' \
132    '-m[output in msb-to-lsb order]' \
133    "-p[don't align EOL codes]" \
134    '-s[duplicate all rows]' \
135    '-v[verbose mode]' \
136    ':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0
137  ;;
138gif2tiff)
139  _arguments -C \
140    '-r[specify rows per strip]:rows per strip' \
141    '-c[specify compression scheme]:compression scheme:->compress' \
142    ':input GIF file:_files -g "*.(#i)gif(-.)"' \
143    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
144  ;;
145ppm2tiff)
146  _arguments -C \
147    '-r[specify rows per strip]:rows per strip' \
148    '-c[specify compression scheme]:compression scheme:->compress' \
149    '-R[specify resolution]:resolution:' \
150    ':input GIF file:_files -g "*.(#i)ppm(-.)"' \
151    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
152  ;;
153ras2tiff)
154  _arguments -C \
155    '-r[specify rows per strip]:rows per strip' \
156    '-c[specify compression scheme]:compression scheme:->compress' \
157    ':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \
158    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
159  ;;
160pal2rgb)
161  _arguments -C \
162    '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \
163    '-p[set sample packing]:sample packing:(contig separate)' \
164    '-c[specify compression scheme]:compression scheme:->compress' \
165    '-r[specify rows per strip]:rows per strip' \
166    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
167    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
168  ;;
169*)
170  _description files expl 'picture file'
171  _files "$expl[@]" -g "$pat" && ret=0
172esac
173
174if [[ -n "$state" ]]; then
175  if [[ "$PREFIX" = *:* ]]; then
176    local scheme="${PREFIX%%:*}"
177
178    compset -P 1 '*:'
179
180    case "$scheme" in
181    g3)
182      _values -s : 'FAX Group 3 options' \
183        '(2d)1d[use 1D-encoding]' \
184        '(1d)2d[use 2D-encoding]' \
185	'fill[byte-align EOL codes]' && ret=0
186      ;;
187    jpeg)
188      _message -e values "compression quality (0-100), or \`r' (output RGB)"
189      ret=0
190      ;;
191    lzw|zip)
192      _values 'LZW and deflate options' \
193        '1[without differencing]' \
194        '2[with differencing]' && ret=0
195      ;;
196    esac
197  else
198    _tags values
199    while _tags; do
200      while _next_label values expl 'compression scheme'; do
201        compadd "$expl[@]" - none g4 packbits && ret=0
202        compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0
203      done
204      (( ret )) || return 0
205    done
206  fi
207fi
208
209return ret
210