forked from tTh/FloatImg
pimping fimg2png
This commit is contained in:
parent
57ef940536
commit
a811beee8a
@ -11,7 +11,7 @@
|
||||
int verbosity;
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
int convertir_fimg_en_PNG(char *srcname, char *dstname, int notused)
|
||||
int convertir_fimg_en_PNG(char *srcname, char *dstname, int grisaille)
|
||||
{
|
||||
int foo, infos[3];
|
||||
FloatImg fimg;
|
||||
@ -22,7 +22,10 @@ fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
|
||||
#endif
|
||||
|
||||
foo = fimg_fileinfos(srcname, infos);
|
||||
if (foo) { fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo); }
|
||||
if (foo) {
|
||||
if (verbosity) fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "image '%s' is %d x %d %s\n",
|
||||
@ -36,6 +39,10 @@ if (foo) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (grisaille) {
|
||||
foo = fimg_desaturate(&fimg, &fimg, 0);
|
||||
}
|
||||
|
||||
foo = fimg_save_as_png(&fimg, dstname, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "saving as png '%s' -> %d\n", dstname, foo);
|
||||
@ -47,18 +54,39 @@ fimg_destroy(&fimg);
|
||||
return 0;
|
||||
}
|
||||
/* ----------------------------------------------------------------- */
|
||||
void help(int k)
|
||||
{
|
||||
|
||||
puts("usage:\n\tfimg2png [options] foo.fimg bar.png");
|
||||
puts("options:");
|
||||
puts("\t-g\tconvert to gray");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
if (verbosity) fimg_print_version(1);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
int foo, opt;
|
||||
int to_gray = 0;
|
||||
|
||||
if (3 != argc) {
|
||||
fimg_print_version(1);
|
||||
fprintf(stderr, "usage:\n\t%s foo.fimg bar.png\n", argv[0]);
|
||||
while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'g': to_gray = 1; break;
|
||||
case 'v': verbosity++; break;
|
||||
case 'h': help(1); exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (2 != argc-optind) {
|
||||
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = convertir_fimg_en_PNG(argv[1], argv[2], 0);
|
||||
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
||||
if (verbosity)
|
||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user