gegl cmd-line ppm patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



New patch...

Cheers,

Henrik

[ppm_bin.diff]

Patch from Henrik Akesson that adds ppm output file format on the
command-line application. It is done by parsing the filename extension
of the --output parameter, which is used to choose the output node
type created (png-save or ppm-save).
* bin/gegl.c
* bin/gegl-options.c
* bin/gegl-options.h
Index: bin/gegl.c
===================================================================
--- bin/gegl.c	(revision 3053)
+++ bin/gegl.c	(working copy)
@@ -251,6 +251,17 @@
           g_object_unref (output);
         }
         break;
+      case GEGL_RUN_MODE_PPM:
+        {
+          GeglNode *output = gegl_node_new_child (gegl,
+						  "operation", "gegl:ppm-save",
+						  "path", o->output,
+						  NULL);
+          gegl_node_connect_from (output, "input", gegl_node_get_output_proxy (gegl, "output"), "output");
+          gegl_node_process (output);
+          g_object_unref (output);
+        }
+        break;
       case GEGL_RUN_MODE_HELP:
         break;
       default:
Index: bin/gegl-options.c
===================================================================
--- bin/gegl-options.c	(revision 3053)
+++ bin/gegl-options.c	(working copy)
@@ -61,7 +61,8 @@
 "     --dot       output a graphviz graph description\n"
 ""
 "     --output    output generated image to named file\n"
-"     -o          (file is saved in PNG format)\n"
+"     -o          (file is saved in PNG or PPM format\n"
+"                  depending on the file ending.)\n"
 "\n"
 "     -p          (increment frame counters of various elements when\n"
 "                  processing is done.)\n"
@@ -246,8 +247,32 @@
 
         else if (match ("--output") ||
                  match ("-o")) {
+            char *trigramstart;
+            int   length;
+
             get_string_forced (o->output);
-            o->mode = GEGL_RUN_MODE_PNG;
+
+            length       = strlen( o->output );
+            trigramstart = o->output;
+            
+            /* position the pointer at the start of the trigram or
+             * if the string is not long enough, at the end of the string */
+            trigramstart += (length > 3 ? length - 3 : length);
+
+            if (strcmp (trigramstart, "png") == 0 ||
+                strcmp (trigramstart, "PNG") == 0 ) {
+
+                o->mode = GEGL_RUN_MODE_PNG;
+            } else if (strcmp (trigramstart, "ppm") == 0 ||
+                       strcmp (trigramstart, "PPM") == 0) {
+
+                o->mode = GEGL_RUN_MODE_PPM;
+            } else {
+                fprintf ( stderr,
+                         "Output file extension not found (%s), using png\n",
+                          o->output);
+                o->mode = GEGL_RUN_MODE_PNG;
+            }
         }
 
         else if (match ("-X")) {
Index: bin/gegl-options.h
===================================================================
--- bin/gegl-options.h	(revision 3053)
+++ bin/gegl-options.h	(working copy)
@@ -27,6 +27,7 @@
   GEGL_RUN_MODE_DOT,
   GEGL_RUN_MODE_EDITOR,
   GEGL_RUN_MODE_PNG,
+  GEGL_RUN_MODE_PPM,
   GEGL_RUN_MODE_XML
 } GeglRunMode;
 
_______________________________________________
Gegl-developer mailing list
Gegl-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer

[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux