This source file includes following definitions.
- main
 
- usage
 
#include "config.h"
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define X_DISPLAY_MISSING
#include <Imlib2.h>
#define PROG_NAME "imlib2_conv"
static void         usage(int exit_status);
int
main(int argc, char **argv)
{
   char               *dot, *colon, *n, *oldn;
   Imlib_Image         im;
   
   for (oldn = n = argv[0]; n; oldn = n)
      n = strchr(++oldn, '/');
   if (argc < 3 || !strcmp(argv[1], "-h"))
      usage(-1);
   if (!(im = imlib_load_image(argv[1])))
     {
        fprintf(stderr, PROG_NAME ": Error loading image: %s\n", argv[1]);
        exit(-1);
     }
   
   imlib_context_set_image(im);
   
   dot = strrchr(argv[2], '.');
   
   if (dot && *(dot + 1))
     {
        colon = strrchr(++dot, ':');
        
        if (colon && *(colon + 1))
          {
             *colon = 0;
             
             if (!strncmp(dot, "db", 2) || !strncmp(dot, "dB", 2) ||
                 !strncmp(dot, "DB", 2) || !strncmp(dot, "Db", 2))
               {
                  imlib_image_set_format("db");
               }
             *colon = ':';
          }
        else
          {
             char               *p, *q;
             
             q = p = malloc(8);
             memset(p, 0, 8);
             strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
             
             for (q[8] = 0; *q; q++)
                *q = tolower(*q);
             imlib_image_set_format(p);
             free(p);
          }
        dot--;
     }
   else
      imlib_image_set_format("jpg");
   imlib_save_image(argv[2]);
   return 0;
}
static void
usage(int exit_status)
{
   fprintf(exit_status ? stderr : stdout,
           PROG_NAME ": Convert images between formats (part of the "
           "Imlib2 package)\n\n"
           "Usage: " PROG_NAME " [ -h | <image1> <image2[.fmt]> ]\n"
           "  <fmt> defaults to jpg if not provided; images in "
           "edb files are supported via\n"
           "        the file.db:/key/name convention.\n"
           "  -h shows this help.\n\n");
   exit(exit_status);
}