/*
- * Simple image manupulation utility
+ * Image Library -- Simple image manipulation utility
*
* (c) 2006 Pavel Charvat <pchar@ucw.cz>
*
-Q --jpeg-quality JPEG quality (1..100)\n\
-g --background background color (hexadecimal RRGGBB)\n\
-G --default-background background applied only if the image contains no background info (RRGGBB, default=FFFFFF)\n\
--a --remove-alpha remove alpha channel\n"
-#ifdef CONFIG_IMAGES_EXIF
-"-e --exif reads Exif data\n"
-#endif
+-a --remove-alpha remove alpha channel\n\
+-e --exif reads Exif data\n"
, stderr);
exit(1);
}
{ "background", 0, 0, 'g' },
{ "default-background", 0, 0, 'G' },
{ "remove-alpha", 0, 0, 'a' },
-#ifdef CONFIG_IMAGES_EXIF
{ "exif", 0, 0, 'e' },
-#endif
{ NULL, 0, 0, 0 }
};
static struct color background_color;
static struct color default_background_color;
static uns remove_alpha;
-#ifdef CONFIG_IMAGES_EXIF
static uns exif;
-#endif
static void
parse_color(struct color *color, byte *s)
case 'a':
remove_alpha++;
break;
-#ifdef CONFIG_IMAGES_EXIF
case 'e':
exif++;
break;
-#endif
default:
usage();
}
if (argc > optind)
output_file_name = argv[optind];
-#define TRY(x) do{ if (!(x)) die("Error: %s", it.err_msg); }while(0)
+#define TRY(x) do{ if (!(x)) exit(1); }while(0)
MSG("Initializing image library");
- struct image_thread it;
+ struct image_context ctx;
struct image_io io;
- image_thread_init(&it);
- if (!image_io_init(&it, &io))
- die("Cannot initialize image I/O (%s)", it.err_msg);
+ image_context_init(&ctx);
+ ctx.tracing_level = ~0U;
+ if (!image_io_init(&ctx, &io))
+ die("Cannot initialize image I/O");
MSG("Reading %s", input_file_name);
io.fastbuf = bopen(input_file_name, O_RDONLY, 1 << 18);
io.format = input_format ? : image_file_name_to_format(input_file_name);
-#ifdef CONFIG_IMAGES_EXIF
if (exif)
io.flags |= IMAGE_IO_WANT_EXIF;
-#endif
TRY(image_io_read_header(&io));
if (!output_file_name)
{
color_put_rgb(rgb, &io.background_color);
printf("Background: %02x%02x%02x\n", rgb[0], rgb[1], rgb[2]);
}
-#ifdef CONFIG_IMAGES_EXIF
if (io.exif_size)
printf("ExifSize: %u\n", io.exif_size);
-#endif
}
else
{
}
image_io_cleanup(&io);
- image_thread_cleanup(&it);
+ image_context_cleanup(&ctx);
MSG("Done.");
return 0;
}