/*
 * Build:
 * $ gcc -o gegl $(pkg-config --cflags --libs gegl) gegl.c
 *
 * Run:
 * $ ./gegl original.png reflected.png
 */

#include <gegl.h>

int
main (int argc, char *argv[])
{
  GeglNode * gegl;
  GeglNode * load;
  GeglNode * operate;
  GeglNode * png_save;
  GeglProcessor * processor;
  gdouble progress;

  if (argv[1] == NULL || argv[2] == NULL)
    {
      return -1;
    }

  gegl_init (&argc, &argv);

  gegl = gegl_node_new ();

  load = gegl_node_new_child (gegl,
                              "operation", "gegl:load",
                              "path", argv[1],
                              NULL);

  operate = gegl_node_new_child (gegl,
                                 "operation", "gegl:rotate",
                                 "degrees", 180.0,
                                 NULL);

  png_save = gegl_node_new_child (gegl,
                                  "operation", "gegl:png-save",
                                  "path", argv[2],
                                  NULL);

  gegl_node_link_many (load, operate, png_save,
                       NULL);

  processor = gegl_node_new_processor (png_save, NULL);
  while (gegl_processor_work (processor, &progress));
  g_object_unref(processor);

  gegl_exit();
  return 0;
}
