X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=images%2Fimage-tool.c;h=e1717569f86ef165331c2856442fc452ac07be13;hb=193043b6628778a997460122f6c796bebe305c95;hp=758000ab08c2014c51c3d01cf0794e409142a296;hpb=f784f9b6365d92dac7b10ab2e589d02c7445e987;p=libucw.git diff --git a/images/image-tool.c b/images/image-tool.c index 758000ab..e1717569 100644 --- a/images/image-tool.c +++ b/images/image-tool.c @@ -184,7 +184,7 @@ main(int argc, char **argv) if (io.background_color.color_space) { byte rgb[3]; - color_put_rgb(rgb, &io.background_color); + TRY(color_put(&ctx, &io.background_color, rgb, COLOR_SPACE_RGB)); printf("Background: %02x%02x%02x\n", rgb[0], rgb[1], rgb[2]); } if (io.exif_size) @@ -216,6 +216,15 @@ main(int argc, char **argv) io.flags |= IMAGE_IO_USE_BACKGROUND; if (jpeg_quality) io.jpeg_quality = jpeg_quality; + uns output_fmt = output_format ? : image_file_name_to_format(output_file_name); + uns output_cs = io.flags & IMAGE_COLOR_SPACE; + if (output_fmt != IMAGE_FORMAT_JPEG && + output_cs != COLOR_SPACE_GRAYSCALE && + output_cs != COLOR_SPACE_RGB) + { + MSG("Forcing RGB color space"); + io.flags = (io.flags & ~IMAGE_COLOR_SPACE) | COLOR_SPACE_RGB; + } TRY(image_io_read_data(&io, 0)); bclose(io.fastbuf); MSG("Writing %s", output_file_name);