1#compdef -P (p[bgpn]m*|*top[bgpn]m)
2
3# Completion for all (or most, you'll never know) pbmplus commands.
4# For some of them there are special cases in the biggish `case' below.
5# Note that since this function is a post-pattern function, these
6# defaults can be overridden by simply defining completion functions
7# for those commands whose arguments you want to complete differently.
8
9local pat expl ret=1
10
11if [[ "$service" = pnm* ]]; then
12  pat='*.(#i)p[bgp]m(-.)'
13elif [[ "$service" = *top[bgpn]m ]]; then
14  pat="*.(#i)${service%%top[bgpn]m}(-.)"
15else
16  pat="*.(#i)${service[1,3]}(-.)"
17fi
18
19if (( $# + $+_in_pbm )); then
20  _wanted files expl 'picture file' _path_files "$@" -g "$pat" - ||
21      _files "$@" "$expl[@]" -g '*.(#i)p[bgp]m(-.)'
22  return
23fi
24
25local _in_pbm=yes
26
27case "$service" in
28asciitop[gn]m)
29  _arguments \
30    '-d[specify divisor]:divisor' \
31    ':height' ':width' ':file:_pbm'
32  ;;
33
34fitstopgm)
35  _arguments \
36    '-image[specify image number]:image number' \
37    ':file:_pbm'
38  ;;
39
40fitstopnm)
41  _arguments \
42    '-image[specify image number]:image number' \
43    '-noraw[produce ASCII pnm file]' \
44    '(-min -max)-scanmax[force scanning data for minimum and maximum]' \
45    '-printmax[only print minimum and maximum values]' \
46    '(-scanmax)-min[override minimum value]:minimum value' \
47    '(-scanmax)-max[override maximum value]:maximum value' \
48    ':file:_pbm'
49  ;;
50
51g3topbm)
52  _arguments \
53    '-kludge[ignore first few lines]' \
54    '-reversebits[interpret bits least-significant first]' \
55    '-stretch[duplicate each row]' \
56    ':file:_pbm'
57  ;;
58
59giftopnm)
60  _arguments \
61    '-alphaout=[output alpha channel]:file:_pbm' \
62    '-verbose[verbose mode]' \
63    '-comments[only print comment fields]' \
64    '-image[specify image number]:image number' \
65    ':file:_pbm'
66  ;;
67
68jpegtopnm)
69  _arguments \
70    '-dct:dct method:(int fast float)' \
71    -{nosmooth,adobe,notadobe,dumpexif,comments,verbose} \
72    '-maxmemory:memory use limit (kB)' \
73    '-exif=:file:_files' \
74    '-tracelevel:trace level' \
75    ':file:_pbm'
76  ;;
77
78macptopbm)
79  _arguments '-extraskip:number of bytes to skip' ':file:_pbm'
80  ;;
81
82pbmclean)
83  if [[ "$PREFIX" = -* ]]; then
84    _message -e neighbours 'maximum number of identical neighbours'
85  else
86    _pbm
87  fi
88  ;;
89
90pbmmake)
91  _arguments \
92    '(-black -gray)-white[produce white pbm file]' \
93    '(-white -gray)-black[produce black pbm file]' \
94    '(-white -black)-gray[produce gray pbm file (stippled)]' \
95    ':width' ':height'
96  ;;
97
98pbmmask)
99  _arguments '-expand[expand mask by one pixel]' ':file:_pbm'
100  ;;
101
102pbmpscale)
103  _arguments ':scale factor' ':file:_pbm'
104  ;;
105
106pbmreduce)
107  _arguments \
108    '(-fs -threshold)-floyd[use Floyd-Steinberg error diffusion]' \
109    '(-floyd -threshold)-fs[use Floyd-Steinberg error diffusion]' \
110    '(-floy -fs)-threshold[use simple thresholding]' \
111    '-value[specify thresholding value]:threshold value' \
112    ':reduction factor' ':file:_pbm'
113  ;;
114
115pbmtext)
116  _arguments \
117    '(-builtin)-font[specify font file]:font file:_files -g "*.(#i)pbm(-.)"' \
118    '(-font)-builtin[select builtin font]:builtin font:(bdf fixed)' \
119    '-space[add space between characters]:space (pixels)' \
120    '*:text'
121  ;;
122
123pbmto10x)
124  _arguments '-h[use resolution 120 x 144]' ':file:_pbm'
125  ;;
126
127pbmtobg|pbmtobbnbg)
128  _arguments ':raster operation' ':x position' ':y position'
129  ;;
130
131pbmtoepsi)
132  _arguments '-bbonly[only create boundary box]' ':file:_pbm'
133  ;;
134
135pbmtolj)
136  _arguments \
137    '-resolution[specify output device resolution]:resolution:(75 100 150 300 600)' \
138    '-float[suppress positioning information]' \
139    "-norest[don't write reset sequences]" \
140    '(-delta -compress)-packbits[enable use of TIFF packbits compression]' \
141    '(-packbits -compress)-delta[enable use of delta-between-rows compression]' \
142    '(-packbits -delta)-compress[enable both compression schemes]' \
143    ':file:_pbm'
144  ;;
145
146pbmtoln03)
147  _arguments \
148    '-l[specify left margin]:left margin' \
149    '-r[specify right margin]:right margin' \
150    '-t[specify top margin]:top margin' \
151    '-b[specify bottom margin]:bottom margin' \
152    '-f[specify form length]:form length' ':file:_pbm'
153  ;;
154
155pbmtolps)
156  _arguments '-dpi[specify output resolution]:resolution' ':file:_pbm'
157  ;;
158
159pbmtomacp)
160  _arguments \
161    '-l[specify left offset]:left offset' \
162    '-r[specify right offset]:right offset' \
163    '-t[specify top offset]:top offset' \
164    '-b[specify bottom offset]:bottom offset' \
165    ':file:_pbm'
166  ;;
167
168pbmtopgm)
169  _arguments ':width' ':height' ':file:_pbm'
170  ;;
171
172pbmtopk)
173  _arguments \
174    '-s[set design size]:design size' \
175    '-C[set coding scheme]:coding scheme' \
176    '-F[set font family comment]:font family' \
177    '-f[specify file with options]:option file:_files' \
178    '*-c[specify next character number]:character number' \
179    '*-W[specify TFM width of next character]:width' \
180    '*-H[specify TFM height of next character]:height' \
181    '*-D[specify TFM depth of next character]:depth' \
182    '*-I[specify italic correction of next character]:italic correction' \
183    '*-h[specify horizontal escapement of next character]:horizontal escapement' \
184    '*-v[specify vertical escapement of next character]:vertical escapement' \
185    '*-x[specify x offset of next character]:x offset' \
186    '*-y[specify y offset of next character]:y offset' \
187    ':pk file:_files -g "*.(#i)pk(-.)"' \
188    ':tfm file:_files -g "*.(#i)tfm(-.)"' \
189    '*:file:_pbm'
190  ;;
191
192pbmupc)
193  _arguments -s{1,2} ':product type' ':manufacturer code' ':product code'
194  ;;
195
196pgmcrater)
197  _arguments \
198    '-number[specify number of craters]:number of craters' \
199    '-gamma[specify gamma correction factor]:gamma factor' \
200    '(-ysize)-height[specify picture height]:height' \
201    '(-height)-ysize[specify picture height]:height' \
202    '(-xsize)-width[specify picture width]:width' \
203    '(-width)-xsize[specify picture width]:width'
204  ;;
205
206pgmkernel)
207  _arguments '-weight:weight' ':width' ':height'
208  ;;
209
210pgmnoise)
211  _arguments ':width' ':height'
212  ;;
213
214pgmnorm|ppmnorm)
215  _arguments \
216    '(-bvalue)-bpercent[specify percentage to map to black]:black percentage' \
217    '(-bpercent)-bvalue[specify pixel value to map to black]:black pixel value' \
218    '(-wvalue)-wpercent[specify percentage to map to white]:white percentage' \
219    '(-wpercent)-wvalue[specify pixel value to map to white]:white pixel value' \
220    ':file:_pbm'
221  ;;
222
223pgmoil)
224  _arguments '-n[specify smear size]:smear size' ':file:_pbm'
225  ;;
226
227pgmramp)
228  _arguments \
229    '(-tb -rectangle -ellipse)-lr[produce left to right ramp]' \
230    '(-lr -rectangle -ellipse)-tb[produce top to bottom ramp]' \
231    '(-lr -tb -ellipse)-rectangle[produce rectangular ramp]' \
232    '(-lr -tb -rectangle)-ellipse[produce elliptical ramp]' \
233    ':width' ':height'
234  ;;
235
236pgmtexture)
237  _arguments '-d[specify distance]:distance' ':file:_pbm'
238  ;;
239
240pgmtopbm)
241  _arguments \
242    '(-fs -threshold -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -clump)-floyd[use FLoyd-Steinberg error diffusion]' \
243    '(-floyd -threshold -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -clump)-fs[use FLoyd-Steinberg error diffusion]' \
244    '(-floyd -fs -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -clump)-threshold[use simple thresholding]' \
245    '(-floyd -fs -threshold -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -value)-hilbert[use space filling curve halftoning (hilbert curve)]' \
246    '(-floyd -fs -threshold -hilbert -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -value -clump)-dither8[use Bayer'"'"'s ordered dither (16 x 16 matrix)]' \
247    '(-floyd -fs -threshold -hilbert -dither8 -cluster3 -c3 -cluster4 -c4 -cluster8 -c8 -value -clump)-d8[use Bayer'"'"'s ordered dither (16 x 16 matrix)]' \
248    '(-floyd -fs -threshold -hilbert -dither8 -d8 -c3 -cluster4 -c4 -cluster8 -c8 -value -clump)-cluster3[use 45 degree clustered dither]' \
249    '(-floyd -fs -threshold -hilbert -dither8 -d8 -cluster3 -cluster4 -c4 -cluster8 -c8 -value -clump)-c3[use 45 degree clustered dither]' \
250    '(-floyd -fs -threshold -hilbert -dither8 -d8 -cluster3 -c3 -c4 -cluster8 -c8 -value -clump)-cluster4[use 45 degree clustered dither]' \
251    '(-floyd -fs -threshold -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -cluster8 -c8 -value -clump)-c4[use 45 degree clustered dither]' \
252    '(-floyd -fs -threshold -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -c8 -value -clump)-cluster8[use 45 degree clustered dither]' \
253    '(-floyd -fs -threshold -hilbert -dither8 -d8 -cluster3 -c3 -cluster4 -c4 -cluster8 -value -clump)-c8[use 45 degree clustered dither]' \
254    '-value[specify thresholding value]:threshold value' \
255    '-clump[specify number of pixels per clump]:number of pixel' \
256    ':file:_pbm'
257  ;;
258
259pgmtoppm)
260  if [[ CURRENT -eq 2 ]]; then
261    if compset -P '?*-'; then
262      _x_color
263      return
264    fi
265    _x_color && ret=0
266
267    _wanted options expl option compadd - -map && ret=0
268
269    return ret
270  elif [[ CURRENT -eq 3 && "$words[2]" = -map ]]; then
271    _description files expl 'map file'
272    _files "$expl[@]" -g '*.(#i)ppm(-.)'
273  else
274    _pbm
275  fi
276  ;;
277
278pktopbm)
279  _arguments \
280    '*-x[set width of next bitmap]:width' \
281    '*-y[set height of next bitmap]:height' \
282    '*-c[set next character number]:character number' \
283    ':pk file:_files -g "*.(#i)pk(-.)"' \
284    '*:file:_pbm'
285  ;;
286
287pngtopnm)
288  _arguments \
289    -{verbose,alpha,mix,time} \
290    '-background:color:_x_color' \
291    '-gamma:value' '-text:file:_files' \
292    ':file:_pbm'
293  ;;
294
295pnmalias)
296  _arguments \
297    '-bgcolor[specify background color]:background color:_x_color' \
298    '-fgcolor[specify background color]:foreground color:_x_color' \
299    '(-bonly)-fonly[apply antialias only to foreground pixels]' \
300    '(-fonly)-bonly[apply antialias only to background pixels]' \
301    '(-balias)-falias[apply antialias to all pixels around foreground pixels]' \
302    '(-falias)-balias[apply antialias to all pixels around foreground pixels]' \
303    '-weight[set central aliasing weight]:central aliasing weight' \
304    ':file:_pbm'
305  ;;
306
307pnmarith)
308  _arguments \
309    '(-)'-{add,subtract,multiply,difference,minimum,maximum} \
310    '*:file:_pbm'
311  ;;
312
313pnmcat)
314  _arguments \
315    '(-black)-white[]' \
316    '(-white)-black[]' \
317    '(-lr -topbottom -tb -jleft -jright)-leftright[place pictures left to right]' \
318    '(-leftright -topbottom -tb -jleft -jright)-lr[place pictures left to right]' \
319    '(-tb -leftright -lr -jtop -jbottom)-topbottom[place pictures top to bottom]' \
320    '(-topbottom -leftright -lr -jtop -jbottom)-tb[place pictures top to bottom]' \
321    '(-topbottom -tb -jbottom -jleft -jright)-jtop[align pictures at top]' \
322    '(-topbottom -tb -jtop -jleft -jright)-jbottom[align pictures at bottom]' \
323    '(-leftright -lr -jright -jtop -jbottom)-jleft[align pictures at left side]' \
324    '(-leftright -lr -jleft -jtop -jbottom)-jright[align pictures at right side]' \
325    '*:file:_pbm'
326  ;;
327
328pnmcomp)
329  _arguments \
330    '-invert[invert overlay pixel values]' \
331    '(-align)-xoff[specify overlay x offset]:x offset' \
332    '(-valign)-yoff[specify overlay y offset]:y offset' \
333    '(-xoff)-align=[specify horizontal alignment for overlay image]:alignment:(left center right)' \
334    '(-yoff)-valign=[specify vertical alignment for overlay image]:alignment:(top middle bottom)' \
335    '-alpha[specify alpha mask file]:alpha mask file:_files -g "*.(#i)pgm(-.)"' \
336    ':overlay file:_pbm' '*:file:_pbm'
337  ;;
338
339pnmconvol)
340  _arguments ':convolution file:_pbm' ':file:_pbm'
341  ;;
342
343pnmcrop)
344  _arguments \
345    '(-black)-white' \
346    '(-white)-black' \
347    -sides \
348    -{left,right,top,bottom} \
349    -verbose \
350    ':file:_pbm'
351  ;;
352
353pnmcut)
354  _arguments \
355    '-left:left col' '-right:right col' '-top:top col' '-bottom:bottom col' \
356    '-width:width' '-height:height' -pad -verbose \
357    ':x position' ':y position' ':width' ':height' ':file:_pbm'
358  ;;
359
360pnmdepth)
361  _arguments ':new maximum value' ':file:_pbm'
362  ;;
363
364pnmenlarge)
365  _arguments ':enlargement factor' ':file:_pbm'
366  ;;
367
368pnmflip)
369  _arguments \
370    \*-{leftright,lr,topbottom,tb,transpose,xy,rotate90,r90,ccw,rotate270,r270,cw,rotate180,r180} \
371    ':file:_pbm'
372  ;;
373
374pnmgamma)
375  _arguments \
376    -ungamma -cieramp \
377    '1:gamma value or red gamma value' \
378    '2: :{ _message -e gamma-values "green gamma value";_pbm }' \
379    '3:blue gamma value' \
380    '4:file:_pbm'
381  ;;
382
383pnmhisteq)
384  _arguments \
385    '-verbose[verbose mode]' \
386    '-gray[modify only gray pixels]' \
387    '-rmap[specify input luminosity map file]:luminosity map file:_files -g "*.(#i)pgm(-.)"' \
388    '-wmap[specify output luminosity map file]:luminosity map file:_files -g "*.(#i)pgm(-.)"' \
389    ':file:_pbm'
390  ;;
391pnmhistmap)
392  _arguments -{black,white,verbose} '-max:maximum value' ':file:_pbm'
393  ;;
394
395pnmindex)
396  _arguments \
397    '-size[set size of index pictures]:image size' \
398    '-across[specify number of pictures per ros]:images per row' \
399    '-colors[specify maximum number of colors]:number of colors' \
400    '-black[use black padding]' \
401    '-title[specify a title to place at the top of the image]:title' \
402    '(-noquant)-quant[enable quantization]' \
403    '(-quant)-noquant[disable quantization]' \
404    '*:file:_pbm'
405  ;;
406
407pnmmargin)
408  _arguments \
409    '(-black -colors)-white' \
410    '(-white -colors)-black' \
411    '(-white -black)-color:color:_x_color' \
412    ':border width' \
413    ':file:_pbm'
414  ;;
415
416pnmnlfilt)
417  _arguments ':alpha value' ':radius' ':file:_pbm'
418  ;;
419
420pnmpad)
421  _arguments \
422    '(-white)-black[add black border]' \
423    '(-black)-white[add white border]' \
424    '-l-[specify left border width]:left border width' \
425    '-r-[specify right border width]:right border width' \
426    '-t-[specify top border width]:top border width' \
427    '-b-[specify bottom border width]: :_guard "[0-9]#" "bottom border width"' \
428    ':file:_pbm'
429  ;;
430
431pnmpaste)
432  _arguments \
433    '(-)'{-replace,-or,-and,-xor} \
434    ':"from" picture file:_pbm' \
435    :{x,y}' position' \
436    ':"into" picture file:_pbm'
437  ;;
438
439pnmrotate)
440  _arguments '-noantialias' ':rotation angle' ':file:_pbm'
441  ;;
442
443pnmscale)
444  local -a scale
445
446  [[ "$words[2]" = -* ]] || scale=( ':scale factor' )
447
448  _arguments \
449    '(-)-reduce:reduction factor' \
450    '(-reduce -xysize -pixels -width -xscale)-xsize:width' \
451    '(-reduce -xysize -pixels -xsize -xscale)-width:width' \
452    '(-reduce -xysize -pixels -height -yscale)-ysize:height' \
453    '(-reduce -xysize -pixels -ysize -yscale)-height:height' \
454    '(-reduce -xysize -pixels -width -xsize)-xscale:horizontal scale factor' \
455    '(-reduce -xysize -pixels -height -ysize)-yscale:vertical scale factor' \
456    '(-width -xsize -height -ysize -xscale -yscale -pixels)-xysize:width::height' \
457    '(-width -xsize -height -ysize -xscale -yscale -xysize)-pixels:total number of pixels' \
458    '-verbose' "$scale[@]" \
459    ':file:_pbm'
460  ;;
461
462pnmshear)
463  _arguments '-noantialias' ':shearing angle' ':file:_pbm'
464  ;;
465
466pnmtile)
467  _arguments ':width' ':height' ':file:_pbm'
468  ;;
469
470pnmtoddif)
471  _arguments \
472    '-resolution:horizontal resolution::vertical resolution' \
473    ':file:_pbm' ':ddif file:_files -g "*.(#i)ddif(-.)"'
474  ;;
475
476pnmtofits)
477  _arguments '-max:maximum value' '-min:minimum value' ':file:_pbm'
478  ;;
479
480pnmtojpeg)
481  _arguments \
482    '--exif=:file:_files' \
483    '--quality=:quality' \
484    --{grayscale,greyscale,optimize,progressive,verbose,baseline} \
485    '--comment=:comment' \
486    '--dct=:dct method:(int fast float)' \
487    '--restart=:rows' \
488    '--smooth=:strength' \
489    '--maxmemory=:memory use limit (kB)' \
490    '--qtables=:file:_files' \
491    '--qslots=:table' \
492    '--sample=:sampling factor' \
493    '--scans:file:_files' \
494    ':file:_pbm'
495  ;;
496
497pnmtopng)
498  _arguments \
499    -{verbose,downscale,interlace,hist,force} \
500    '-alpha:file:_files' '-gamma:value' \
501    '-transparent::color:_x_color' '-background:color:_x_color' \
502    '-chroma:wx::wy::rx::ry::gx::gy::bx::by' \
503    '-phys:x::y::unit' \
504    '-text:file:_files' '-ztxt:file:_files' \
505    '-time:date ([yy]yy-mm-dd)::time (hh:mm:ss)' \
506    '-filter:type:((0\:none 1\:sub 2\:up 3\:avg 4\:paeth))' \
507    '-compression:level:(0 1 2 3 4 5 6 7 8 9)' \
508    ':file:_pbm'
509  ;;
510
511pnmtops)
512  _arguments \
513    '(-noturn)-turn' '(-turn)-noturn' \
514    '(-nocenter)-center '(-center)-nocenter \
515    '(-rle)-runlength' '(-runlength)-rle' \
516    '(-imagewidth -imageheight)-scale:scale factor' \
517    '-dpi:output resolution' \
518    '(-scale -equalpixels)-imagewidth:width on page (inches)' \
519    '(-scale -equalpixels)-imageheight:height on page (inches)' \
520    '-width:page width' '-height:page height' \
521    '(-imagewidth -imageheight)-equalpixels' \
522    ':file:_pbm'
523  ;;
524
525pnmtorast)
526  _arguments '(-rle)-standard' '(-standard)-rle' ':file:_pbm'
527  ;;
528
529pnmtosgi)
530  _arguments \
531    '(-rle)-verbatim' '(-verbatim)-rle' \
532    '-imagename:image name' \
533    ':file:_pbm'
534  ;;
535
536pnmtotiff)
537  _arguments \
538    '(-packbits -lzw -g3 -g4 -2d -fill -predictor)-none' \
539    '(-none -lzw -g3 -g4 -2d -fill -predictor)-packbits' \
540    '(-none -packbits -g3 -g4 -2d -fill -predictor)-lzw' \
541    '(-none -packbits -lzw -g4 -predictor)-g3' \
542    '(-none -packbits -lzw -g3 -2d -fill -predictor)-g4' \
543    '-2d' \
544    '-fill' '-minisblack' \
545    '(-lsb2msb)-msb2lsb' \
546    '(-msb2lsb)-lsb2msb' \
547    '-predictor:LZW predictor:((1\:without\ differencing 2\:with\ differencing))' \
548    '-rowsperstrip:number of rows per strip' ':file:_pbm'
549  ;;
550
551pnmtoxwd)
552  _arguments \
553    '-pseudodepth:depth of PseudoColor dumps' '-directcolor' \
554    ':file:_pbm'
555  ;;
556
557ppm3d)
558  _arguments :{left,right}' picture file:_pbm' ':horizontal offset'
559  ;;
560
561ppmbrighten)
562  _arguments \
563    '-n[normalize value]' \
564    '-s[specify saturation difference]:saturation difference' \
565    '-v[specify value difference]:value difference' \
566    ':file:_pbm'
567  ;;
568
569ppmchange)
570  local curcontext="$curcontext" state line
571
572  _arguments -C \
573    "-closeness[specify how close a pixel's color should be]:closeness (percent)" \
574    '-remainder[specify replacement for colours not given explicit replacement]:color:_x_color' \
575    '*: :->args' && ret=0
576
577  if [[ -n "$state" ]]; then
578    if (( CURRENT & 1 )); then
579      _wanted colors expl 'new color' _x_color && ret=0
580    else
581      _alternative \
582	'files:file:_pbm' \
583	'colors:old color:_x_color' && ret=0
584    fi
585  fi
586
587  return ret
588  ;;
589
590ppmdim)
591  _arguments ':diminishing factor' ':file:_pbm'
592  ;;
593
594ppmdist)
595  _arguments \
596    '(-frequency)-intensity[sort colors by grayscale intensity]' \
597    '(-intensity)-frequency[sort colors by frequency]' \
598    ':file:_pbm'
599  ;;
600
601ppmdither)
602  _arguments \
603    '-dim:matrix size' \
604    '-red:number of red shades' \
605    '-green:number of green shades' \
606    '-blue:number of blue shades' \
607    ':file:_pbm'
608  ;;
609
610ppmflash)
611  _arguments ':flash factor' ':file:_pbm'
612  ;;
613
614ppmforge)
615  _arguments \
616    -{clouds,night} \
617    '-dimension:fractal dimension' '-hour:hour angle' \
618    '(-tilt)-inclination:inclination angle' \
619    '(-inclination)-tilt:inclination angle' \
620    '-mesh:FFT mesh size' '-power:elevations power factor' \
621    '-glaciers:glacier elevation' '-ice:polar ice cap extent' \
622    '-saturation:star color saturation' \
623    '-seed:random number seed' \
624    '-stars:minimum star pixel percentage' \
625    '(-xsize)-width:width'   '(-width)-xsize:width' \
626    '(-ysize)-height:height' '(-height)-ysize:height'
627  ;;
628
629ppmmake)
630  _arguments ':color:_x_color' ':width' ':height'
631  ;;
632
633ppmmix)
634  _arguments ':fade factor' ':file:_pbm' ':file:_pbm'
635  ;;
636
637ppmntsc)
638  _arguments ':dim factor' ':file:_pbm'
639  ;;
640
641ppmpat)
642  _arguments \
643    '(-)'-{gingham{2,3},g{2,3},madras,tartan,poles,squig,camo,anticamo} \
644    ':width' ':height'
645  ;;
646
647ppmquant)
648  local opt=yes
649
650  if [[ "$words[2]" = -(fs|floyd) ]]; then
651    (( CURRENT-- ))
652    shift 1 words
653    opt=''
654  fi
655
656  if [[ CURRENT -eq 2 ]]; then
657    if [[ -n "$opt" ]]; then
658      _wanted options expl option compadd - -map -fs -floyd && ret=0
659    else
660      _wanted options expl option compadd - -map && ret=0
661    fi
662    _message -e numbers 'number of colors'
663
664    return ret
665  elif [[ CURRENT -eq 3 && "$words[2]" = -map ]]; then
666    _description files expl 'map file'
667    _files "$expl[@]" -g '*.(#i)ppm(-.)'
668  else
669    _pbm
670  fi
671  ;;
672
673ppmquantall)
674  _arguments \
675    '-ext:extension' ': :_guard "[0-9]#" "number of colors"' \
676    '*:file:_pbm'
677  ;;
678
679ppmshift)
680  _arguments ':shift value' ':file:_pbm'
681  ;;
682
683ppmspread)
684  _arguments ':maximum spread amount' ':file:_pbm'
685  ;;
686
687ppmtoacad)
688  _arguments \
689    '(-poly)-dxb[write AutoCAD binary database import file]' \
690    '(-dxb)-poly[render pixels as filled polygons]' \
691    '-8[restrict colors to the 8 RGB shades]' \
692    '(-background)-white[use white background]' \
693    '(-white)-background:background color (0-255)' \
694    '-aspect:pixel aspect ratio' \
695    ':file:_pbm'
696  ;;
697
698ppmtobmp)
699  _arguments \
700    '(-windows)-os2' '(-os2)-windows' \
701    '-bpp[specify bits per pixel for BMP file]:bits per pixel:(1 4 8 24)' \
702    ':file:_pbm'
703  ;;
704
705ppmtogif)
706  _arguments \
707    '-interlace[produce interlaced GIF]' \
708    '-sort[produce GIF with sorted color map]' \
709    '-map[use colors in specified file]:map file:_files' \
710    '(-alpha)-transparent[specify transparent color]:color' \
711    '(-transparent)-alpha[specify PGM file containing alpha mask]:file:_pbm' \
712    '-comment[include a comment in the GIF file]:comment text' \
713    '-nolxw[skip LZW compression]' \
714    ':file:_pbm'
715  ;;
716
717ppmtoicr)
718  _arguments \
719    '-windowname:window name' '-expand:expansion factor' \
720    '-display:display screen' '-rle' ':file:_pbm'
721  ;;
722
723ppmtoilbm)
724  _arguments \
725    '(-mp -maxplanes)'{-mp,-maxplanes}':planes' \
726    '(-fp -fixplanes)'{-fp,-fixplanes}':planes' \
727    '(-hambits -hamplanes)'{-hambits,-hamplanes}':planes' \
728    -normal -hamif -24if -dcif -hamforce -24force -dcforce \
729    '(-dcbits -dcplanes)'{-dcbits,-dcplanes}':bits for red: :bits for green: :bits for blue' \
730    -ecs -aga -ham6 -ham8 -compress '-cmethod:method:(none byterun1)' \
731    '-map:ppm file:_pbm' -cmaponly -savemem \
732    ':file:_pbm'
733  ;;
734
735ppmtomap)
736  _arguments -s{ort,quare} ':file:_pbm'
737  ;;
738
739ppmtomitsu)
740  _arguments \
741    '-sharpness:sharpness:(1 2 3 4)' \
742    '-enlarge:enlargement factor:(1 2 3)' \
743    '-media:output media (default\: 1184x1350):((A\:1216x1350 A4\:1184x1452 AS\:1216x1650 A4S\:1184x1754))' \
744    '-copy:number of copies:(1 2 3 4 5 6 7 8 9)' \
745    -{dpi300,tiny} ':file:_pbm'
746  ;;
747
748ppmtopcx)
749  _arguments -{24bit,packed} ':file:_pbm'
750  ;;
751
752ppmtopj)
753  _arguments \
754    '-gamma:gamma value' '-xpos:x position' -{rle,center} \
755    '-ypos:y position' '-back:background brightness:(dark lite)' \
756    '-render:rendering algorithm:(none snap bw dither diffuse monodither monodiffuse clusterdither monoclusterdither)' \
757    ':file:_pbm'
758  ;;
759
760ppmtopjxl)
761  _arguments \
762    -{nopack,presentation,dark,diffuse,cluster,dither} \
763    '-gamma:gamma value' \
764    '-xshift:x shift' '-yshift:y shift' \
765    '(-width -xscale)-xscale:width' \
766    '(-xsize -xscale)-width:width' \
767    '(-xsize -width)-xscale:horizontal scale factor' \
768    '(-height -yscale)-ysize:height' \
769    '(-ysize -yscale)-height:height' \
770    '(-ysize -height)-yscale:vertical scale factor' \
771    ':file:_pbm'
772  ;;
773
774ppmtosixel)
775  _arguments -{raw,margin} ':file:_pbm'
776  ;;
777
778ppmtotga)
779  _arguments -{mono,cmap,rgb,norle} ':file:_pbm'
780  ;;
781
782ppmtouil)
783  _arguments '-name:name prefix' ':file:_pbm'
784  ;;
785
786ppmtorle)
787  _arguments \
788    '-name=:name prefix' \
789    '-rgb=:X11 rgb file:_files' \
790    '-alphamask=:pgm file:_pbm' \
791    ':file:_pbm'
792  ;;
793
794ppmtoyuvsplit)
795  _arguments ':base name' ':file:_pbm'
796  ;;
797
798psidtopgm)
799  _arguments \
800    ':width' ':height' ':bits per sample' \
801    ':postscript file:_files -g "*.(#i)(ps|eps)(-.)"'
802  ;;
803pstopnm)
804  _arguments \
805    '(-portrait)-landscape' \
806    '(-landscape)-portrait' \
807    '(-pgm -ppm)-pbm' \
808    '(-pbm -ppm)-pgm' \
809    '(-pbm -pgm)-ppm' \
810    -{forceplain,help,nocrop,verbose} \
811    '-llx:loxer left x position' '-lly:lower left y position' \
812    '-urx:upper right x position' '-ury:upper right y position' \
813    '-xborder:x border fraction' '-yborder:y border fraction' \
814    '-xmax:maximum width' '-ymax:maximum height' \
815    '-xsize:width' '-ysize:height' \
816    ':postscript file:_files -g "*.(#i)(ps|eps)(-.)"'
817  ;;
818
819rawtopgm)
820  _arguments \
821    '-maxval:value' \
822    '-bpp:bytes:(1 2)' \
823    -littleendian \
824    '(-bt -bottomfirst -rowskip)-'{bt,bottomfirst} \
825    '-headerskip:header bytes to skip' \
826    '(-bt -bottomfirst)-rowskip:row padding to skip' \
827    ': :_guard "[0-9]#" width' ':height' ':grayscale bytes'
828  ;;
829
830rawtoppm)
831  _arguments \
832    '-headerskip:header bytes to skip' \
833    '-rowskip:row padding to skip' \
834    '(-rgb -rbg -grb -gbr -brg -bgr)'-{rgb,rbg,grb,gbr,brg,bgr} \
835    '(-interrow)-interpixel' \
836    '(-interpixel)-interrow' \
837    ': :_guard "[0-9]#" width' ':height' ':grayscale bytes'
838  ;;
839
840rgb3toppm)
841  if [[ CURRENT -eq 2 ]]; then
842    expl='red picture file'
843  elif [[ CURRENT -eq 3 ]]; then
844    expl='green picture file'
845  elif [[ CURRENT -eq 4 ]]; then
846    expl='blue picture file'
847  fi
848
849  if [[ -n "$expl" ]]; then
850    _description files expl "$expl"
851    _files "$expl" -g '*.(#i)pgm(-.)'
852  fi
853  ;;
854
855rletopnm)
856  _arguments \
857    '--alphaout=:alpha file:_pbm' \
858    -{h,-headerdump,v,-verbose,p,-plain} \
859    ':file:_pbm'
860  ;;
861
862sgitopnm)
863  _arguments '-verbose' '-channel:channel' ':file:_pbm'
864  ;;
865
866sldtoppm)
867  _arguments \
868    -{adjust,dir,info,verbose} \
869    '(-width -xsize)'-{width,xsize}:width \
870    '(-height -ysize)'-{height,ysize}:height \
871    '-scale:scale factor' \
872    '(-lib -Lib)'-{l,L}'ib:slide name' \
873    ':file:_pbm'
874  ;;
875
876yuvsplittoppm)
877  _arguments ':base name' ':width' ':height' '-ccir601'
878  ;;
879
880yuvtoppm)
881  _arguments ':width' ':height' ':image bytes'
882  ;;
883
884zeisstopnm)
885  _arguments '(-pgm -ppm)'-p{g,p}m ':file:_pbm'
886  ;;
887
888*)
889  _wanted files expl 'picture file' _path_files -g "$pat" ||
890      _files "$expl[@]" -g '*.(#i)p[bgp]m(-.)'
891esac
892