*/
#include "lib/lib.h"
-#include "lib/getopt.h"
#include "lib/fastbuf.h"
#include "images/images.h"
#include "images/color.h"
+
+#include <getopt.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
exit(1);
}
-static char *shortopts = "qf:F:s:b:c:Q:g:" CF_SHORT_OPTS;
+static char *shortopts = "qf:F:s:b:c:Q:g:";
static struct option longopts[] =
{
- CF_LONG_OPTS
{ "quiet", 0, 0, 'q' },
{ "input-format", 0, 0, 'f' },
{ "output-format", 0, 0, 'F' },
{
log_init(argv[0]);
int opt;
- while ((opt = cf_getopt(argc, argv, shortopts, longopts, NULL)) >= 0)
+ while ((opt = getopt_long(argc, argv, shortopts, longopts, NULL)) >= 0)
switch (opt)
{
case 'q':
}
if (background_color.color_space)
io.background_color = background_color;
+ else if (!io.background_color.color_space)
+ io.background_color = color_white;
if (channels_format)
io.flags = io.flags & ~IMAGE_PIXEL_FORMAT | channels_format;
if (!(io.flags & IMAGE_ALPHA))
break;
case IMAGE_FORMAT_UNDEFINED:
- // FIXME: auto-detect
+#if defined (CONFIG_IMAGES_LIBMAGICK)
+ return libmagick_read_header(io);
+#endif
break;
default:
#endif
break;
+ case IMAGE_FORMAT_UNDEFINED:
+#if defined(CONFIG_IMAGES_LIBMAGICK)
+ result = libmagick_read_data(io);
+#else
+ ASSERT(0);
+#endif
+ break;
+
default:
ASSERT(0);
}
default:
break;
}
- image_thread_err(io->thread, IMAGE_ERR_INVALID_FILE_FORMAT, "Image format not supported.");
+ image_thread_err(io->thread, IMAGE_ERR_INVALID_FILE_FORMAT, "Output format not supported.");
return 0;
}
if (io->cols != rdi->image->cols || io->rows != rdi->image->rows)
{
DBG("Scaling image");
- rdi->need_transformations = ((io->flags ^ rdi->image->flags) & IMAGE_NEW_FLAGS);
- struct image *img = image_new(io->thread, io->cols, io->rows, rdi->image->flags, rdi->need_transformations ? NULL : io->pool);
+ uns flags = rdi->image->flags;
+ if (!(rdi->need_transformations = ((io->flags ^ rdi->image->flags) & (IMAGE_NEW_FLAGS & ~IMAGE_PIXELS_ALIGNED))))
+ flags = io->flags;
+ struct image *img = image_new(io->thread, io->cols, io->rows, flags, rdi->need_transformations ? NULL : io->pool);
if (unlikely(!img))
{
image_destroy(rdi->image);
rdi->image = img;
}
+ // FIXME: support for various color spaces
+
ASSERT(!rdi->need_transformations);
}