summaryrefslogtreecommitdiff
path: root/src/gegltest.c
blob: 420155611a5355d43bf23a7566cd4edfc29a5781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <gegl.h> 

gint
main (gint    argc,
      gchar **argv)
{
  GeglNode *graph, *src, *sink;
  GeglBuffer *buffer = NULL;

  gegl_init (&argc, &argv);

  if (argc != 3)
    {
      g_print ("GEGL based image conversion tool\n");
      g_print ("Usage: %s <imageA> <imageB>\n", argv[0]);
      return 1;
    }

  graph = gegl_node_new ();
  src   = gegl_node_new_child (graph,
                               "operation", "gegl:load",
                               "path", argv[1],
                                NULL);
  sink  = gegl_node_new_child (graph,
                               "operation", "gegl:buffer-sink",
                               "buffer", &buffer,
                                NULL);

  gegl_node_link_many (src, sink, NULL);

  gegl_node_process (sink);
  g_object_unref (graph);

  /* FIXME: Currently a buffer will always be returned, even if the source is missing */
  if (!buffer)
    {
      g_print ("Failed to open %s\n", argv[1]);
      return 1;
    }

  graph = gegl_node_new ();
  src   = gegl_node_new_child (graph,
                               "operation", "gegl:buffer-source",
                               "buffer", buffer,
                                NULL);
  sink  = gegl_node_new_child (graph,
                               "operation", "gegl:save",
                               "path", argv[2],
                                NULL);

  gegl_node_link_many (src, sink, NULL);

  gegl_node_process (sink);
  g_object_unref (graph);

  g_object_unref (buffer); 
  gegl_exit ();
  return 0;
}