/* Copyright (c) 2009 Christian Dywan <christian@lanedo.com>
   This code is licensed under the terms of the expat license */

/* gcc -o a a.c $(pkg-config --cflags --libs gtk+-2.0) -Wall -O1 -g */

#include <string.h>
#include <gtk/gtk.h>

int
main (int    argc,
      gchar *argv[])
{
  GError *error;
  GdkPixbuf *pixbuf;

  gtk_init_check (&argc, &argv);

  if (argc != 3)
    g_error ("Usage: %s INFILE OUTFILE", argv[0]);

  if (!g_path_is_absolute (argv[1]) || !g_path_is_absolute (argv[2]))
    g_error ("Usage: %s INFILE OUTFILE", argv[0]);

  error = NULL;
  pixbuf = gdk_pixbuf_new_from_file (argv[1], &error);
  if (error)
    g_error (error->message);
  g_debug ("compression of INFILE: %s",
           gdk_pixbuf_get_option (pixbuf, "compression"));

  gdk_pixbuf_save (pixbuf, argv[2], "tiff", &error, "compression", "7", NULL);
  if (error)
    g_error (error->message);

  return 0;
}
