1 | #include "config.h" |
---|
2 | #include "common.h" |
---|
3 | |
---|
4 | #include <stdio.h> |
---|
5 | #include <stdlib.h> |
---|
6 | #include <string.h> |
---|
7 | |
---|
8 | #include <pipi.h> |
---|
9 | |
---|
10 | int main(int argc, char *argv[]) |
---|
11 | { |
---|
12 | pipi_context_t *ctx; |
---|
13 | |
---|
14 | ctx = pipi_create_context(); |
---|
15 | |
---|
16 | while(*++argv) |
---|
17 | { |
---|
18 | if(!strcmp(argv[0], "--dup")) |
---|
19 | { |
---|
20 | if(pipi_command(ctx, "dup") != 0) |
---|
21 | return EXIT_FAILURE; |
---|
22 | } |
---|
23 | else if(!strcmp(argv[0], "--dither")) |
---|
24 | { |
---|
25 | if(argv[1] == NULL) |
---|
26 | return EXIT_FAILURE; |
---|
27 | if(pipi_command(ctx, "dither", argv[1]) != 0) |
---|
28 | return EXIT_FAILURE; |
---|
29 | argv++; |
---|
30 | } |
---|
31 | else if(!strcmp(argv[0], "--blur")) |
---|
32 | { |
---|
33 | if(argv[1] == NULL) |
---|
34 | return EXIT_FAILURE; |
---|
35 | if(pipi_command(ctx, "blur", argv[1]) != 0) |
---|
36 | return EXIT_FAILURE; |
---|
37 | argv++; |
---|
38 | } |
---|
39 | else if(!strcmp(argv[0], "--gray")) |
---|
40 | { |
---|
41 | if(pipi_command(ctx, "gray") != 0) |
---|
42 | return EXIT_FAILURE; |
---|
43 | } |
---|
44 | else if(!strcmp(argv[0], "--autocontrast")) |
---|
45 | { |
---|
46 | if(pipi_command(ctx, "autocontrast") != 0) |
---|
47 | return EXIT_FAILURE; |
---|
48 | } |
---|
49 | else if(!strcmp(argv[0], "--wrap")) |
---|
50 | { |
---|
51 | if(pipi_command(ctx, "wrap") != 0) |
---|
52 | return EXIT_FAILURE; |
---|
53 | } |
---|
54 | else if(!strcmp(argv[0], "--mean")) |
---|
55 | { |
---|
56 | if(pipi_command(ctx, "mean") != 0) |
---|
57 | return EXIT_FAILURE; |
---|
58 | } |
---|
59 | else if(!strcmp(argv[0], "--min")) |
---|
60 | { |
---|
61 | if(pipi_command(ctx, "min") != 0) |
---|
62 | return EXIT_FAILURE; |
---|
63 | } |
---|
64 | else if(!strcmp(argv[0], "--max")) |
---|
65 | { |
---|
66 | if(pipi_command(ctx, "max") != 0) |
---|
67 | return EXIT_FAILURE; |
---|
68 | } |
---|
69 | else if(!strcmp(argv[0], "--sub")) |
---|
70 | { |
---|
71 | if(pipi_command(ctx, "sub") != 0) |
---|
72 | return EXIT_FAILURE; |
---|
73 | } |
---|
74 | else if(!strcmp(argv[0], "--add")) |
---|
75 | { |
---|
76 | if(pipi_command(ctx, "add") != 0) |
---|
77 | return EXIT_FAILURE; |
---|
78 | } |
---|
79 | else if(!strcmp(argv[0], "--output") || !strcmp(argv[0], "-o")) |
---|
80 | { |
---|
81 | if(argv[1] == NULL) |
---|
82 | return EXIT_FAILURE; |
---|
83 | if(pipi_command(ctx, "save", argv[1]) != 0) |
---|
84 | return EXIT_FAILURE; |
---|
85 | argv++; |
---|
86 | } |
---|
87 | else |
---|
88 | { |
---|
89 | if(pipi_command(ctx, "load", argv[0]) != 0) |
---|
90 | return EXIT_FAILURE; |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|
94 | pipi_destroy_context(ctx); |
---|
95 | |
---|
96 | return EXIT_SUCCESS; |
---|
97 | } |
---|
98 | |
---|