tweaking...

This commit is contained in:
tth 2021-04-05 20:49:01 +02:00
parent 393112fb9b
commit 6dc9aab6ba
1 changed files with 14 additions and 5 deletions

View File

@ -12,7 +12,7 @@
int verbosity; int verbosity;
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
int faire_un_halfsize(char *iname, char *oname, int notused) int faire_un_halfsize(char *iname, char *oname, int to_gray)
{ {
FloatImg src, dst; FloatImg src, dst;
int foo; int foo;
@ -30,6 +30,11 @@ if (foo) {
return -1; return -1;
} }
if (to_gray) {
foo = fimg_to_gray(&dst);
}
foo = fimg_dump_to_file(&dst, oname, 0); foo = fimg_dump_to_file(&dst, oname, 0);
if (foo) { if (foo) {
fprintf(stderr, "save to '%s' -> %d\n", oname, foo); fprintf(stderr, "save to '%s' -> %d\n", oname, foo);
@ -48,13 +53,15 @@ void help(int u)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo, opt, action; int foo, opt;
char *srcname = ""; char *srcname = "";
char *dstname = "out.fimg"; char *dstname = "out.fimg";
int grayed = 0;
while ((opt = getopt(argc, argv, "hv")) != -1) { while ((opt = getopt(argc, argv, "ghv")) != -1) {
switch(opt) { switch(opt) {
case 'g': grayed = 1; break;
case 'h': help(0); break; case 'h': help(0); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
@ -68,10 +75,12 @@ if (2 != argc-optind) {
srcname = argv[optind]; srcname = argv[optind];
dstname = argv[optind+1]; dstname = argv[optind+1];
fprintf(stderr, "%s: optind: %d src: %s dst: %s\n", argv[0], optind, if (verbosity) {
fprintf(stderr, "%s: src: %s dst: %s\n", argv[0],
srcname, dstname); srcname, dstname);
}
foo = faire_un_halfsize(srcname, dstname, 0); foo = faire_un_halfsize(srcname, dstname, grayed);
return 0; return 0;