summary refs log tree commit diff
path: root/Completion/Unix/Command/_tiff
blob: ef12777de25ba6493766f1dec1674050ade9f547 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#compdef -P (tiff*|*2tiff|pal2rgb)

local pat expl ret=1

if [[ "$service" = *2tiff ]]; then
  pat="*.(#i)${service}(-.)"
else
  pat='*.(#i)tiff(-.)'
fi

if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then
  if (( ! $# )); then
    _description files expl 'picture file'
    set -- "$expl[@]"
  fi
  _wanted files expl 'picture file' _path_files "$@" -g "$pat" - ||
      _files "$@" "$expl[@]" -g '*.(#i)tif(|f)(-.)'
  return
fi

local _in_tiff=yes

local curcontext="$curcontext" state line ret=1
typeset -A opt_args

case "$service" in
tiff2bw)
  _arguments -C \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-r+[specify rows per strip]:rows per strip' \
    '-R+[specify percentage of red channel]:percentage' \
    '-G+[specify percentage of green channel]:percentage' \
    '-B+[specify percentage of blue channel]:percentage' \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':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]' \
    '-m+[set memory allocation limit]:limit (MiB)' \
    '(- :)-h[display usage information]' \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"'
  ;;
tiff2ps)
  _arguments -s \
    '!(-2 -3 -8 -m)-1' \
    '(-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]' \
    '-b+[set the bottom margin]:margin (inches)' \
    '-c[center image]' \
    '-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"]' \
    '-M+[set memory allocation limit]:limit (MiB)' \
    '-o+[set initial TIFF directory (file offset)]:file offset (bytes)' \
    '(-e)-p[generate non-Encapsulated PostScript]' \
    '-O+[specify output file]:output file:_files -g "*.(#i)(|e)ps(-.)"' \
    '-P+[set PageOrientation DSC comment to Landscape or Portrait]:orientation:(L P)' \
    '-r+[rotate image]:rotation:(90 180 270 auto)' \
    '-s[generate output for a single image]' \
    '-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
  ;;
tiffcmp)
  _arguments -s \
    '-l[list all differing bytes]' \
    '-z+[list specified number of bytes that differs between the files]:bytes' \
    '-t[ignore differences in directories]' \
    ':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
tiffcp)
  _arguments -C -s \
    '-a[append to output instead of overwriting]' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-o+[set initial TIFF directory (file offset)]:file offset' \
    '-p+[set sample packing]:sample packing:(contig separate)' \
    '(-t)-s[write output in strips]' \
    '(-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]' \
    '-b+[specify bias (dark) monochrome image to be subtracted from all others]:file:_files' \
    '-,=-[specify substitute character for image indices]:character [,]' \
    '-m+[set memory allocation limit]:limit (MiB)' \
    '-r+[specify rows per strip]:rows per strip' \
    '-w+[specify output tile width]:output tile width' \
    '-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)
  _arguments -C \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \
    '-r+[specify rows per strip]:rows per strip' \
    '-t+[set threshold for dithering]:dither threshold value [128]' \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
tiffdump)
  _arguments \
    '-o+[set initial TIFF directory (file offset)]:file offset' \
    '-h[print numbers in hexadecimal]' \
    '-m+[change number of indirect items printed]:items [24]' \
    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
tiffinfo)
  _arguments -s \
    '-c[display colormap and color/gray response curves]' \
    '-D[read and decompress data]' \
    '-d[print decompressed data]' \
    '-j[display JPEG-related tags]' \
    '-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]' \
    '-i[ignore read errors]' \
    '-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \
    '-w[display raw data in words]' \
    '-z[enable strip chopping]' \
    '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
tiffmedian)
  _arguments -C \
    '-r+[specify rows per strip]:rows per strip' \
    '-C+[specify number of colormap entries]:number of colormap entries' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-f[use Floyd-Steinberg dithering]' \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
tiffsplit)
  _arguments \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':output file prefix' && ret=0
  ;;
fax2tiff)
  _arguments -s \
    '!(-1 -2 -3 -4)-'{1,3} \
    '(-1 -4)-2[input is Group 3, 2d encoded]' \
    '(-1 -2 -A)-4[input is Group 4 encoded]' \
    '-U[input is uncompressed]' \
    '(-4)-A[input is EOL-aligned]' \
    '-B[0 in input means black]' \
    '-M[input is msb-to-lsb]' \
    '-R+[specify resolution]:resolution (lines per inch) [196]' \
    '-X+[specify input data width]:width [1728]' \
    '-o+[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \
    '(-5 -p)-8[generate G4-encoded output]' \
    '-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]' \
    '-r+[specify rows per strip]:rows per strip' \
    '-s[stretch image by duplicating all rows]' \
    '-v[verbose mode]' \
    '-z[generate LZW compressed output]' \
    ':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0
  ;;
gif2tiff)
  _arguments -C \
    '-r+[specify rows per strip]:rows per strip' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    ':input GIF file:_files -g "*.(#i)gif(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
ppm2tiff)
  _arguments -C \
    '-r+[specify rows per strip]:rows per strip' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-R+[specify resolution]:resolution (dots/inch)' \
    ':input GIF file:_files -g "*.(#i)ppm(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
ras2tiff)
  _arguments -C \
    '-r+[specify rows per strip]:rows per strip' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    ':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
pal2rgb)
  _arguments -C \
    '-C+[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \
    '-p+[set sample packing]:sample packing:(contig separate)' \
    '-c+[specify compression scheme]:compression scheme:->compress' \
    '-r+[specify rows per strip]:rows per strip' \
    ':input file:_files -g "*.(#i)tif(|f)(-.)"' \
    ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
  ;;
*)
  _description files expl 'picture file'
  _files "$expl[@]" -g "$pat" && ret=0
esac

if [[ -n "$state" ]]; then
  if [[ "$PREFIX" = *:* ]]; then
    local scheme="${PREFIX%%:*}"

    compset -P 1 '*:'

    case "$scheme" in
    g3)
      _values -s : 'FAX Group 3 option' \
        '(2d)1d[use 1D-encoding]' \
        '(1d)2d[use 2D-encoding]' \
	'fill[byte-align EOL codes]' && ret=0
      ;;
    jpeg)
      _message -e values "compression quality (0-100), or \`r' (output RGB)"
      ret=0
      ;;
    lzw|lzma|zip|zstd|webp)
      _values 'LZW and deflate option' \
        '1[without differencing]' \
        '2[with differencing]' && ret=0
      ;;
    esac
  else
    _tags values
    while _tags; do
      while _next_label values expl 'compression scheme'; do
        compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0
        compadd "$expl[@]" -qS: - lzw zip lzma zstd webp jpeg g3 && ret=0
      done
      (( ret )) || return 0
    done
  fi
fi

return ret